var xmlhttp; functionloadXMLDoc(url) { xmlhttp=null; if (window.XMLHttpRequest){// code for all new browsers xmlhttp=new XMLHttpRequest(); //创建xml对象 } elseif (window.ActiveXObject){// code for IE5 and IE6 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp!=null){ xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4){// 4 = "loaded" 整个请求过程已经完毕
if (xmlhttp.status==200){请求的响应状态码 (例如, 状态码200 表示一个成功的请求). // ...our code here...TODO } else{ alert("Problem retrieving XML data"); } } } xmlhttp.open("GET",url,true); xmlhttp.send(null); } else{ alert("Your browser does not support XMLHTTP."); } }