首页 > 试题广场 >

写出原生Ajax

var xhr ;
if(window.XMLHttpRequest){
xhr = new XMLHttpRequest();
}
else{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.open("GET",url);
xhr.send();
xhr.onreadystatechange=function(){
if(xhr.readyState===4){
if(xhr.status>=200&&xhr.status<300||xhr.status===304){
succes***r />
}
else{
error();
}
}
};
编辑于 2019-05-15 19:37:55 回复(0)
var xhr= new XMLHttprequest();
xhr.open("GET", "xxx");
xhr.send();
发表于 2019-04-07 11:02:11 回复(0)