//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 2017-03-03 11:36  weimo10235  阅读(486)  评论(0)    收藏  举报