﻿// JScript 文件
function Ajax(){this._oXmlHttp=null;if(window.ActiveXObject){var arrIE=["MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];for(var i=0;i<4;i++){try{ this._oXmlHttp=new ActiveXObject(arrIE[i]);} catch (Err){}}}if (typeof XMLHttpRequest != "undefined") {this._oXmlHttp= new XMLHttpRequest();}}Ajax.prototype._addParam=function(s){var reg=new RegExp("(?:&)?=([^&]*)&?","g");while(reg.test(s)){s=s.replace(RegExp.$1,encodeURIComponent(RegExp.$1));}return s;}
Ajax.prototype.getText=function(){return this._oXmlHttp.responseText;};
Ajax.prototype.getXML=function(){return this._oXmlHttp.responseXML;};
Ajax.prototype.getState=function(){return this._oXmlHttp.readyState;};
Ajax.prototype.getStatus=function(){return this._oXmlHttp.status;};
Ajax.prototype.execute=function(sURL,sParam,sMethod,eHandle){//发送异步请求
sMethod=sMethod.toLowerCase();sParam=this._addParam(sParam);try{if(sMethod=="get"){this._oXmlHttp.open("get",sURL+"?"+sParam,true);sParam="";}else if(sMethod=="post")    {this._oXmlHttp.open("post",sURL,true);this._oXmlHttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");this._oXmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}this._oXmlHttp.onreadystatechange=eHandle;this._oXmlHttp.send(sParam);}catch(e){alert("发送请求失败由于:\\r\\r"+e.message);}};






