window.reqObjPool = new ReqObjPool();
function ReqObjPool(){// Request Object Pool
this.pool = new Array();
this.getReqObj=function(){
var micXhrV = ["Msxml2.XMLHTTP","Microsoft.XMLHTTP"];//micsoft XMLHttpRequest Verstion
var xhr = this.pool.pop();//XMLHttpRequest
if(xhr==null){
if (Browser.IE)
for(var v in micXhrV)try{xhr=new ActiveXObject(micXhrV[v]);break;}catch(e){}
else
xhr=new XMLHttpRequest();
}
return xhr;
}
this.getBackReqObj=function(xhr){this.pool.push(xhr);xhr.abort();}
}
function HttpRequest(){
this.isAsync = true;
this.ll = new Array();//listener List
this.addListener=function(listener){this.ll.push(listener);}
this.clearListener=function(){this.ll.length=0;}
function send(ll,xhr,url,method,args,isAsync){
xhr.onreadystatechange=function(){
for(var v in ll)ll[v](xhr);
if(xhr.readyState==4||xhr.readyState==0)reqObjPool.getBackReqObj(xhr)
}
xhr.open(method,url,isAsync);
xhr.send(args);
}
this.post=function(url,args){send(this.ll,reqObjPool.getReqObj(),url,"POST",args,this.isAsync);}
this.get=function(url){send(this.ll,reqObjPool.getReqObj(),url,"GET",null,this.isAsync);}
}
/*----------------------------------------------*/
*使用举例:
*var hr = new HttpRequest();
* hr.addListener(function(xhr){if(xhr.readyState==4)alert(xhr.resposeText);});
*hr.get("getUserName.do","userId=11");
*
*------------------------------------------------*/
在此推荐一下: 饰装修评价推荐查询网 http://www.zhuangxiu007.com
function ReqObjPool(){// Request Object Pool
this.pool = new Array();
this.getReqObj=function(){
var micXhrV = ["Msxml2.XMLHTTP","Microsoft.XMLHTTP"];//micsoft XMLHttpRequest Verstion
var xhr = this.pool.pop();//XMLHttpRequest
if(xhr==null){
if (Browser.IE)
for(var v in micXhrV)try{xhr=new ActiveXObject(micXhrV[v]);break;}catch(e){}
else
xhr=new XMLHttpRequest();
}
return xhr;
}
this.getBackReqObj=function(xhr){this.pool.push(xhr);xhr.abort();}
}
function HttpRequest(){
this.isAsync = true;
this.ll = new Array();//listener List
this.addListener=function(listener){this.ll.push(listener);}
this.clearListener=function(){this.ll.length=0;}
function send(ll,xhr,url,method,args,isAsync){
xhr.onreadystatechange=function(){
for(var v in ll)ll[v](xhr);
if(xhr.readyState==4||xhr.readyState==0)reqObjPool.getBackReqObj(xhr)
}
xhr.open(method,url,isAsync);
xhr.send(args);
}
this.post=function(url,args){send(this.ll,reqObjPool.getReqObj(),url,"POST",args,this.isAsync);}
this.get=function(url){send(this.ll,reqObjPool.getReqObj(),url,"GET",null,this.isAsync);}
}
/*----------------------------------------------*/
*使用举例:
*var hr = new HttpRequest();
* hr.addListener(function(xhr){if(xhr.readyState==4)alert(xhr.resposeText);});
*hr.get("getUserName.do","userId=11");
*
*------------------------------------------------*/
在此推荐一下: 饰装修评价推荐查询网 http://www.zhuangxiu007.com