[原创]自己做的一个AJAX简单连接池
<P>function AjaxObj()<BR>{<BR> this.PoolContent = 10;<BR> this.XmlHttpObjList = new Array(this.PoolContent);<BR> this.CreateXmlHttpObj = JS_CreateXmlHttpObj;<BR> this.getXmlHttpObj = JS_getXmlHttpObj;<BR>}<BR>function JS_CreateXmlHttpObj()<BR>{<BR> var xmlHttp = false;<BR> <A>/*@cc_on</A> @*/<BR> <A>/*@if</A> (@_jscript_version >= 5)<BR> try {<BR> xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");<BR> } catch (e) {<BR> try {<BR> xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");<BR> } catch (e2) {<BR> xmlHttp = false;<BR> }<BR> }<BR> @end @*/</P><P> if (!xmlHttp && typeof(XMLHttpRequest)!="undefined") {<BR> xmlHttp = new XMLHttpRequest();<BR> }<BR> return xmlHttp;<BR>}</P>
<P>function JS_getXmlHttpObj()<BR>{<BR> for(var i=0;i<this.PoolContent;i++)<BR> {<BR> if(this.XmlHttpObjList[i] == null)<BR> {<BR> return (this.XmlHttpObjList[i]=this.CreateXmlHttpObj());<BR> }<BR> else<BR> {<BR> if(this.XmlHttpObjList[i].readyState == 4 || this.XmlHttpObjList[i].readyState == 0)<BR> {<BR> return this.XmlHttpObjList[i];<BR> }<BR> else<BR> {<BR> continue;<BR> }<BR> }<BR> }<BR> alert("网络状态正忙,请稍后再试!");<BR>}</P> <P>我刚开始学<BR><BR><BR> 敬礼</P> 支持... 学习一下[em01]
页:
[1]
