var pool_xmlreq=function(){
var _cachecase=[];
_cachecase.fetch=function(){
var i=0;
var _instance=function(){
try{
return (new activexobject(msxml2.xmlhttp.5.0));}
catch(e){
try{
return (new xmlhttprequest());}
catch(e){
try{
return (new activexobject(msxml2.xmlhttp));}
catch(e){
try{
return (new activexobject(microsoft.xmlhttp));}
catch(e){
alert(error: initializing xmlhttprequest!);}}}}}
for(;i if(this[i].readystate==0||this[i].readystate==4){
return this[i];}}
this[i]=_instance();
return this[i];}
this.length=function(){
return _cachecase.length}
this.instance=function(){
return _cachecase.fetch()}
this.connect=function(method,url,data,handler){
var _xmlhttpreq=_cachecase.fetch();
with(_xmlhttpreq){
open(method,url,true);
setrequestheader(cache-control,no-cache);
setrequestheader(content-type,application/x-www-form-urlencoded;charset=utf-8);
send(data);
onreadystatechange=function(){
if(_xmlhttpreq.readystate return false;
if(_xmlhttpreq.status==200||_xmlhttpreq.status==304){
handler(decodeuricomponent(_xmlhttpreq.responsetext));
return true;}
alert(error: status_+_xmlhttpreq.status+!);
return false;}}}
}
var xmlreq=new pool_xmlreq();
用法:
xmlreq.connect(post,url,postdata,function);
