网站首页 网站建设 IT知识 IT知识教程 javascript:以前写的xmlhttp池,代码

javascript:以前写的xmlhttp池,代码

2021-05-26 21:26:43
varPool_xmlreq=function(){
var_cacheCase=[];
_cacheCase.fetch=function(){
vari=0;
var_instance=function(){
try{
return(newActiveXObject("Msxml2.XMLHTTP.5.0"));}
catch(e){
try{
return(newXMLHttpRequest());}
catch(e){
try{
return(newActiveXObject("Msxml2.XMLHTTP"));}
catch(e){
try{
return(newActiveXObject("Microsoft.XMLHTTP"));}
catch(e){
alert("Error:initializingxmlhttprequest!");}}}}}
for(;i<this.length;i++){
if(this[i].readyState==0||this[i].readyState==4){
returnthis[i];}}
this[i]=_instance();
returnthis[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-ponent(_xmlhttpreq.responseText));
returntrue;}
alert("Error:status_"+_xmlhttpreq.status+"!");
returnfalse;}}}
}
varxmlreq=newPool_xmlreq();

用法:
xmlreq.connect("post",url,postdata,function);

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。 如涉及版权问题,请提交至online#300.cn邮箱联系删除。

以上产品还未完全满足我的所有需求,在下方提交我的专属需求
我的专属需求:
*手机号:
*验证码:
img
咨询报价
现在咨询
img

在线咨询

建站在线咨询

img

微信咨询

扫一扫添加
动力姐姐微信

img
img

TOP