首页 > IT职业 > IT生活 > js创建ajax简单代码,解析XML
var xmlHttp;
if(window.ActiveXObject){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
xmlHttp.onreadystatechange=function(){
var result;
if(xmlHttp.readyState===4){
if(xmlHttp.status===200){
document.title=xmlHttp.responseXML.getElementsByTagName("response")[0].childNodes[0].nodeValue;
}
}
}
xmlHttp.open("get","response.xml");
xmlHttp.send(null); message 来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2505/viewspace-2798228/ ,如需转载,请注明出处,否则将追究法律责任。