?? xmlhttp.js
字號:
function XMLHttpClient(instanceName){ this.instanceName=instanceName; this.xmlhttp = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... this.xmlhttp = new XMLHttpRequest(); if (this.xmlhttp.overrideMimeType) { this.xmlhttp.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE try { this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!this.xmlhttp) { alert('無法創(chuàng)建組件:XMLHTTP,可能由于瀏覽器版本太低或瀏覽器部分組件已損壞。'); }}XMLHttpClient.prototype.open=function(method,url,Async){ this.xmlhttp.open(method,url,Async); if (method == "POST"||method == "post") { this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); }}XMLHttpClient.prototype.attachOnChange=function(instanceName){ this.xmlhttp.onreadystatechange=function() { if(window[instanceName].xmlhttp.readyState==4) { window[instanceName].fireOnStatus(window[instanceName].xmlhttp.status); } }}XMLHttpClient.prototype.getState=function(){ return this.xmlhttp.readyState;}XMLHttpClient.prototype.setRequestHeader=function(header,value){ this.xmlhttp.setRequestHeader(header,value);}XMLHttpClient.prototype.send=function(post_data){ this.xmlhttp.send(post_data); this.attachOnChange(this.instanceName);}XMLHttpClient.prototype.attachOnStatus=function(Status,func){ this["onStatus_"+Status.toString()]=func;}XMLHttpClient.prototype.fireOnStatus=function(status){ if(this["onStatus_"+status]) this["onStatus_"+status](this.xmlhttp); else this["onStatus_default"](this.xmlhttp);}XMLHttpClient.prototype.onStatus_default=function(xmlhttp){ alert("通訊異常,錯誤號:"+xmlhttp.status.toString()+"!");}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -