//Ajax四部曲
util.xhrGo = function(req,route,judge,callback,isnull){
var xhr = this.createXHR();//创建请求
xhr.open(req,route,judge);//open这个url
xhr.onreadystatechange = function(){
if (xhr.readyState == 4) {
if ((xhr.status>=200&&xhr.status<300)||xhr.status==304) {
var result = JSON.parse(xhr.responseText);
callback(result);
}else{
throw new Error("异步请求出错!");
}
}
};//状态监测
xhr.send(isnull);//发送请求
}
posted on
浙公网安备 33010602011771号