function Ajax() { debug=false; if(typeof(___xmlhttp___)=="undefined") { ___xmlhttp___=new Array();//条件编译开始 /*@cc_on @if (@_jscript_version >= 5) ___xmlhttp___[0]= new ActiveXObject("Msxml2.XMLHTTP")|| new ActiveXObject("Microsoft.XMLHTTP") @else @*/ ___xmlhttp___[0]=typeof(___xmlhttp___[0])=="undefined"?new XMLHttpRequest():___xmlhttp___[0]; /* @end @*/ } if(typeof(leisure)=="undefined")//自动复用空闲ajax控件,开始 { leisure="index"; } for(var i=0;i<___xmlhttp___.length;i++) { if(___xmlhttp___[i].readyState==0||___xmlhttp___[i].readyState==4) { leisure=i; break; } } if(leisure=="index") { leisure=___xmlhttp___.length; try { ___xmlhttp___.push( new ActiveXObject("Msxml2.XMLHTTP")|| new ActiveXObject("Microsoft.XMLHTTP")); } catch (e) { ___xmlhttp___.push(new XMLHttpRequest()); } } var ajaxobj=___xmlhttp___[leisure];//自动复用空闲ajax控件,结束 this.post=function(url,feedback,arg,loading) { if(feedback==null) { feedback=function() { }; } if(loading==null) { loading=function() { }; } this.open(url,"POST",feedback,loading,arg,true); }; this.get=function(url,feedback,loading) { if(feedback==null) { feedback=function() { }; } if(loading==null) { loading=function() { }; } this.open(url,"GET",feedback,loading,"",true); }; this.send=function(url,feedback,method,arg) { if(feedback==null) { feedback=function() { }; } this.open(url,method,feedback,function() { } ,arg,true); }; this.dom=function(str) { try { var dom_soap=new ActiveXObject("Microsoft.XMLDOM"); dom_soap.async = false; dom_soap.loadXML(str); return dom_soap; } catch(e) { var soap=new DOMParser(); var dom_soap=soap.parseFromString(str,"text/xml"); return dom_soap; } }; this.open = function(url, method, feedback,process, arg,asyc) { var asy=true; if(asyc!=null) { asy=asyc; } if(arguments.length==2) { feedback=method; method="post"; } method = method.toUpperCase(); try { ajaxobj.setRequestHeader("Cache-Control: no-store, no-cache, must-revalidate"); ajaxobj.setRequestHeader("Connection","open"); } catch(e) { } try { if (method == "GET") { ajaxobj.open(method, url+"?"+arg,asy); arg = ""; } else { ajaxobj.open(method, url, asy); try { ajaxobj.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); } catch(e) { } } ajaxobj.send(arg); if(asy) { __feedback__=function() { if (ajaxobj.readyState == 4) { if(ajaxobj.status==200||ajaxobj.status==0) { try { var json=eval(unescape(ajaxobj.responseText).replace(/[|]/g,"
")); } catch(e) { var json=[]; } try { feedback(unescape(ajaxobj.responseText),ajaxobj,json); } catch(e) { } } else { try { feedback(ajaxobj.status); } catch(e) { } } } else { try { process(ajaxobj.readyState); } catch(e) { } } }; ajaxobj.onreadystatechange =__feedback__ ; } else { try { var json=eval(ajaxobj.responseText.replace(/[|]/g,"
")); } catch(e) { var json=[]; } feedback(ajaxobj.responseText,ajaxobj,json); } } catch(z) { return false; } return true; }; this.connect=function(url,method,feedback,arg,asyc)//ajax长连接 { if(navigator.userAgent.toLowerCase().indexOf("msie") == -1) { var objRequest= new XMLHttpRequest(); objRequest.multipart=true; objRequest.open("POST",url+"?"+arg, true); objRequest.onload = function(event){ var dmm=event.target.responseXML.documentElement.childNodes.item(0); feedback([dmm.nodeValue.match(/(['|"]?([^)'"]+)['|"]?)/)[1],dmm.nodeName,event.target.responseText,event.target]); }; objRequest.send(null); } else//IE上的实现是通过htmlfile控件+iframe { fbajax= new ActiveXObject("htmlfile"); fbajax.Charset="utf-8"; fbajax.open(); fbajax.write(""); fbajax.write(""); fbajax.write(""); fbajax.close(); fbajax.write(""); fbajax.onafterupdate=function(){alert(80)};//激活htmlfile控件防止被回收 fbajax.parentWindow.feedback=function(o,o1,o2,o3,o4,o5,o6,o7,o8) { feedback([o,o1,o2,o3,o4,o5,o6,o7,o8]); } } }; /* *AJAX,监听方法 */ this.onload=function(url,feedback,arg) { if(feedback==null) { feedback=function() { }; } debug?alert(url):""; this.connect(url,"post",feedback,arg,false); }; }; //Get Form Item function GetFormItem(objForm) { if(!objForm) { alert("Don't Set objForm!") return; } var f=eval("document."+objForm+".elements"); var objForm="document."+objForm; var str=""; var strCheckbox=""; var strSelect=""; for(i=0;i