亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我用ajax調用文本內容,但是在瀏覽其中就是沒法顯示,請大神們幫幫忙?。?!謝謝了??!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Ajax</title></head><body><div id="new" ></div><script>function getHTTPObject(){ if(typeof XMLHttpRequest=="undefined") ?XMLHttpRequest=function(){ ?try{return new ActiveXObject("Msxml2.XMLHTTP.6.0");} ?catch(e){} ?try{return new ActiveXObject("Msxml2.XMLHTTP.3.0");} ?catch(e){} ?try{return new ActiveXObjec("Msxml2.XMLHTTP");} ?catch(e){} ?try{return new ActiveXObject("Microsoft.XMLHTTP");} ?catch(e){} ?return false; ?} ?return new XMLHttpRequest(); } function getNewContent(){ var request=getHTTPObject(); if(request){ request.open("GET","example.txt",true); request.onreadystatechange=function(){ if(request.readyState==4){ var para= document.createElement("p"); var txt=document.createTextNode(request.responseText); para.appendChild(txt); document.getElementById('new').appendChild(para); } }; request.send(null); }else{ alert('Sorry,your browser dont\'t support XMLhttpRequest'); } alert("Function Done") } function addLoadEvent(func){ var onload=window.onload; if(typeof (window.onload) !='function'){ window.onload=func; }else{ window.onload=function(){ onload(); func(); } } }addLoadEvent(getNewContent);addLoadEvent(getHTTPObject);</script></body></html>文本和這個html在一個文件夾下,txt內容:你好!
查看完整描述

3 回答

?
Elem

TA貢獻4條經驗 獲得超2個贊

換個瀏覽器。非http請求,有的瀏覽器不支持

查看完整回答
反對 回復 2016-12-10
?
杰杰就是我

TA貢獻32條經驗 獲得超24個贊

我運行的結果為 彈出?Function Done , 然后頁面出現 你好! ?不知道你想表達的是什么錯誤?

查看完整回答
反對 回復 2016-12-09
  • 3 回答
  • 0 關注
  • 1482 瀏覽
慕課專欄
更多

添加回答

了解更多

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號