var AjaxHelp={
var GetXhr:function(){
var xhr;
if(windows.XMLHttpRequest){
xhr=new XMLHttpRequest();
}esle
{
xhr=new ActiveXObject("Microsoft.XMLHTTP");
}
},
var AjaxProcess:function(url,method,params,callback){
var xhr=this.GetXhr();//1 .0 创建异步对象
xhr.open();//2 发送请求
if (method.toLowerCase=="get"){
xhr.setRquestHeader("If-Modified-Since","0");
} else {
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}
xhr.onreadystatechange=function(){//4 设置请求状态变换事件
if(xhr.readstate==4&&xhr.Status==200){
var resText=JSON.parse(xhr.ReponseText);//返回结果
}
}
xhr.Send(params);//发送请求
}
};
网友评论