function DedeAjax(WiteOKFunc){ this.xhttp = null; this.xdom = null; this.keys = Array(); this.values = Array(); this.keyCount = -1; this.rkeys = Array(); this.rvalues = Array(); this.rkeyCount = -1; this.rtype = 'text'; if(window.XMLHttpRequest){ this.xhttp = new XMLHttpRequest(); }else if(window.ActiveXObject){ try { this.xhttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) { } if (this.xhttp == null) try { this.xhttp = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { } } this.xhttp.onreadystatechange = WiteOKFunc; this.InitXDom = function(){ var obj = null; if (typeof(DOMParser) != "undefined") { var parser = new DOMParser(); obj = parser.parseFromString(xmlText, "text/xml"); } else { // IE try { obj = new ActiveXObject("MSXML2.DOMDocument");} catch (e) { } if (obj == null) try { obj = new ActiveXObject("Microsoft.XMLDOM"); } catch (e) { } } this.xdom = obj; }; this.AddKey = function(skey,svalue){ this.keyCount++; this.keys[this.keyCount] = skey; this.values[this.keyCount] = escape(svalue); }; this.AddHead = function(skey,svalue){ this.rkeyCount++; this.rkeys[this.rkeyCount] = skey; this.rvalues[this.rkeyCount] = svalue; }; this.ClearSet = function(){ this.keyCount = -1; this.keys = Array(); this.values = Array(); this.rkeyCount = -1; this.rkeys = Array(); this.rvalues = Array(); }; this.SendHead = function(){ if(this.rkeyCount!=-1){ for(;i<=this.rkeyCount;i++){ this.xhttp.setRequestHeader(this.rkeys[i],this.rvalues[i]); } } if(this.rtype=='binary'){ this.xhttp.setRequestHeader("Content-Type","multipart/form-data"); }else{ this.xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); } }; this.SendPost = function(purl){ var pdata = ""; var i=0; this.state = 0; this.xhttp.open("POST", purl, true); this.SendHead(); if(this.keyCount!=-1){ for(;i<=this.keyCount;i++){ if(pdata=="") pdata = this.keys[i]+'='+this.values[i]; else pdata += "&"+this.keys[i]+'='+this.values[i]; } } this.xhttp.send(pdata); }; this.SendGet = function(purl){ var gkey = ""; var i=0; this.state = 0; if(this.keyCount!=-1){ for(;i<=this.keyCount;i++){ if(gkey=="") gkey = this.keys[i]+'='+this.values[i]; else gkey += "&"+this.keys[i]+'='+this.values[i]; } if(purl.indexOf('?')==-1) purl = purl + '?' + gkey; else purl = purl + '&' + gkey; } this.xhttp.open("GET", purl, true); this.SendHead(); this.xhttp.send(); }; }