XMLHttpRequest是什麽、如何完整地運行一次GET請求、如何檢測錯誤。
阿新 • • 發佈:2017-05-13
var obj problem get請求 () == name xmlhttp 如何
var xmlhttp; function LoadXmlDoc(url){ xmlhttp = null; if(window.XMLHttpRequest){ //code for all new browsers xmlhttp=new XMLHttpRequest(); }else if(window.ActiveXObject){//IE5 and IE6 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } if(xmlhttp!=null){ xmlhttp.onreadystatechange=function (){ if(xmlhttp.readyState==4){ // loaded ... if(xmlhttp.state==200){ //success,...our code here ... }else{ alert(‘Problem retrieving XMl data‘); } } } } }
XMLHttpRequest是什麽、如何完整地運行一次GET請求、如何檢測錯誤。