www.gusucode.com > DEDECMS精简版 织梦CMS系统企业精简版 v3.0.1.2源码程序 > cloudcms_v3.0.1.2/cloud/js/dedeajax.js
DedeXHTTP = null; DedeXDOM = null; DedeContainer = null; function $(eid){ return document.getElementById(eid); } function $DE(id) { return document.getElementById(id); } function DedeAjax(gcontainer){ DedeContainer = gcontainer; this.keys = Array(); this.values = Array(); this.keyCount = -1; this.rkeys = Array(); this.rvalues = Array(); this.rkeyCount = -1; this.rtype = 'text'; if(window.ActiveXObject){ try { DedeXHTTP = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) { } if (DedeXHTTP == null) try { DedeXHTTP = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { } } else{ DedeXHTTP = new XMLHttpRequest(); } DedeXHTTP.onreadystatechange = function(){ if(DedeXHTTP.readyState == 4){ if(DedeXHTTP.status == 200){ DedeContainer.innerHTML = DedeXHTTP.responseText; DedeXHTTP = null; }else DedeContainer.innerHTML = "下载数据失败"; }else DedeContainer.innerHTML = "正在下载数据..."; }; 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++){ DedeXHTTP.setRequestHeader(this.rkeys[i],this.rvalues[i]); } } if(this.rtype=='binary'){ DedeXHTTP.setRequestHeader("Content-Type","multipart/form-data"); }else{ DedeXHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); } }; this.SendPost = function(purl){ var pdata = ""; var i=0; this.state = 0; DedeXHTTP.open("POST", purl, true); this.SendHead(); if(this.keyCount!=-1){ //post数据 for(;i<=this.keyCount;i++){ if(pdata=="") pdata = this.keys[i]+'='+this.values[i]; else pdata += "&"+this.keys[i]+'='+this.values[i]; } } DedeXHTTP.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; } DedeXHTTP.open("GET", purl, true); this.SendHead(); DedeXHTTP.send(null); }; } function InitXDom(){ if(DedeXDOM!=null) return; var obj = null; if (typeof(DOMParser) != "undefined") { // Gecko、Mozilla、Firefox 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) { } } DedeXDOM = obj; };