亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

AJAX創(chuàng)建XMLHttpRequest對象

AJAX創(chuàng)建XMLHttpRequest對象:
當(dāng)前所有的主流瀏覽器都支持XMLHttpRequest對象。
此對象可以用來在后臺與服務(wù)器進行數(shù)據(jù)交換,于是也就使異步更新網(wǎng)頁內(nèi)容成為可能,不用刷新整個頁面。
特別說明:IE5和IE6使用ActiveXObject。
創(chuàng)建XMLHttpRequest對象兼容IE5和IE6:
(1).創(chuàng)建XMLHttpRequest對象方式如下:

var xmlhttp=new XMLHttpRequest();

(2).兼容IE5和IE6(使用ActiveX對象):

var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

兼容性代碼如下:

var xmlhttp;
//IE7和IE7以上或者其他標(biāo)準(zhǔn)瀏覽器
if (window.XMLHttpRequest){
  xmlhttp=new XMLHttpRequest();
}
//IE5和IE6瀏覽器
else{
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
繼續(xù)學(xué)習(xí)
||
<html><!DOCTYPE html> <html> <head> <script> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } //可以自己創(chuàng)建txt文件進行修改 xmlhttp.open("GET","/asset/demo.ajax.php?dm=txt&act=getfruits",true); xmlhttp.send(); } </script> </head> <body> <div id="myDiv"><h2>使用 AJAX 修改該文本內(nèi)容</h2></div> <button type="button" onclick="loadXMLDoc()">修改內(nèi)容</button> </body> </html>
提交重置代碼