1/* 2* The DynaXmlHttp object. 3* Example: 4* var dynaXmlhttp = new DynaXmlHttp(); 5 dynaXmlhttp.enableDebug(); 6 dynaXmlhttp.setAction("http://localhost/CmbBank_GenShell/UI/GenShellPC/Login/GenLogin.aspx"); 7 8 dynaXmlhttp.addParam("a","avalue"); 9 dynaXmlhttp.addParam("b","bvalue"); 10 11 var xmlhttpobj = createXmlHttp(); 12 13 dynaXmlhttp.setXmlHttpObj(xmlhttpobj); 14 15 if(dynaXmlhttp.send()) 16 { 17 alert(dynaXmlhttp.getResponseText()); 18 19 } 20* 21*/ 22 23function DynaXmlHttp() 24{ 25 this.action = ""; 26 this.method = "post"; 27 this.xmlhttpObj = null; 28 this.requestParams = new Object(); 29 this.asyncFlag = false; 30 this.onreadystatechange = null; 31 this.debug = false; 32} 33new DynaXmlHttp(); 34 35function EnableDebug() 36{ 37 this.debug = true; 38} 39DynaXmlHttp.prototype.enableDebug = EnableDebug; 40 41function SetOnreadystatechange(onreadystatechange) 42{ 43 this.onreadystatechange = onreadystatechange; 44} 45 46function SetAsyncFlag(bAsync) 47{ 48 if(bAsync) this.asyncFlag = true; 49 else this.asyncFlag = false; 50} 51DynaXmlHttp.prototype.setAsyncFlag = SetAsyncFlag; 52function GetAsyncFlag() 53{ 54 return this.asyncFlag; 55} 56DynaXmlHttp.prototype.GetAsyncFlag = GetAsyncFlag; 57 58function SetXmlHttpObj(xmlhttpObj) 59{ 60 this.xmlhttpObj = xmlhttpObj; 61} 62DynaXmlHttp.prototype.setXmlHttpObj = SetXmlHttpObj; 63function GetXmlHttpObj() 64{ 65 return this.xmlhttpObj; 66} 67DynaXmlHttp.prototype.GetXmlHttpObj = GetXmlHttpObj; 68 69function SetMethod(method) 70{ 71 this.method = method; 72} 73DynaXmlHttp.prototype.setMethod = SetMethod; 74function GetMethod() 75{ 76 return this.method; 77} 78DynaXmlHttp.prototype.GetMethod = GetMethod; 79 80 81function SetAction(action) 82{ 83 this.action = action; 84} 85DynaXmlHttp.prototype.setAction = SetAction; 86function GetAction() 87{ 88 return this.action; 89} 90DynaXmlHttp.prototype.getAction = GetAction; 91 92function AddParam(name,value) 93{ 94 this.requestParams[name] = value; 95} 96DynaXmlHttp.prototype.addParam = AddParam; 97 98function AddParams(obj) 99{ 100 for(var attr in obj) 101 { 102 if (attr == "event") continue; //For Safari; 103 this.requestParams[attr] = obj[attr]; 104 } 105} 106DynaXmlHttp.prototype.addParams = AddParams; 107 108function ProcessAsyncResponse() 109{ 110 alert(this.xmlhttpObj.readyState); 111/* 112 if(this.xmlhttpObj.readyState == 4) 113 { 114 if(this.xmlhttpObj.status == 200) 115 { 116 alert(this.xmlhttpObj.responseText); 117 } 118 else 119 { 120 alert(this.xmlhttpObj.statusText); 121 } 122 } 123 */ 124} 125DynaXmlHttp.prototype.processAsyncResponse = ProcessAsyncResponse; 126 127function Send() 128{ 129 130 if(this.xmlhttpObj == null) 131 { 132 alert("Please set a xmlhttp object first"); 133 return false; 134 } 135 if(!this.xmlhttpObj) 136 { 137 alert("Xmlhttp object init failed"); 138 return false; 139 } 140 if(this.asyncFlag) 141 { 142 if(this.onreadystatechange == null) 143 { 144 alert("Please set event handler for onreadystatechange in async mode"); 145 //return false; 146 } 147 this.xmlhttpObj.onreadystatechange = this.processAsyncResponse; 148 } 149 this.xmlhttpObj.open(this.method,this.action,this.asyncFlag); 150 151 //this.xmlhttpObj.setRequestHeader("Content-Type","text/xml;charset=GB2312"); 152 if(this.method.toLowerCase() == "post") 153 { 154 this.xmlhttpObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 155 } 156 157 var params = ""; 158 for(var attr in this.requestParams) 159 { 160 params += "&"+attr+"="; 161 params += encodeURIComponent(this.requestParams[attr]); 162 } 163 params = params.substr(1); 164 165 if(this.debug) 166 { 167 alert(params); 168 } 169 this.xmlhttpObj.send(params); 170 return true; 171} 172DynaXmlHttp.prototype.send = Send; 173 174function GetResponseText() 175{ 176 return this.xmlhttpObj.responseText; 177} 178DynaXmlHttp.prototype.getResponseText = GetResponseText; 179 180function GetResponseXML() 181{ 182 return this.xmlhttpObj.responseXML; 183} 184DynaXmlHttp.prototype.getResponseXML = GetResponseXML; 185 186function GetResponseHeader(headVar) 187{ 188 return this.xmlhttpObj.getResponseHeader(headVar); 189} 190DynaXmlHttp.prototype.getResponseHeader = GetResponseHeader;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.