aien,i@ruboy.com,1034555083
Ajax (A,B,C,D,E,F,G);
Parameter description: A-request method; B-Request address; C-requested data, A is valid for post; D-callback function, the This reference within the function is a XMLHTTP object; E is asynchronous, unless set to false; f,g-logon username and password
function Ajax (A,B,C,D,E,F,G) {
A = A.touppercase ();
if (e===false) {e=false;} Else{e = true;}
var obj = Ajax.ajax_getobj ();
if (obj) {
if (f) {
Obj.open (A,B,E,F,G);
}else{
Obj.open (a,b,e);
}
if (a.touppercase () = = "Post") {
Obj.setrequestheader ("Content-type", "application/x-www-form-urlencoded");
}
Obj.onreadystatechange=function () {if (typeof D!= "function") {return;} D.apply (Obj,[a,b,c,d,e,f,g]);
Obj.send (c);
}
}
Ajax.ajax_getobj = function () {
var b = null;
if (window.activexobject) {//for ie
var httplist = ["msxml2.xmlhttp.5.0", "msxml2.xmlhttp.4.0", "msxml2.xmlhttp.3.0", "Msxml2.xmlhttp", " Microsoft.XMLHTTP "];
for (var i = httplist.length-1;i >= 0;i--) {
try{
b = new ActiveXObject (httplist[i]);
return b;
}catch (ex) {}
}
}else if (window.xmlhttprequest) {//for other
b = new XMLHttpRequest ();
}
return b;
}
A simpler way to two
Ajax.ajax_getobj = function () {
var b = null;
if (window.activexobject) {//for ie
var httplist = ["msxml2.xmlhttp.5.0", "msxml2.xmlhttp.4.0", "msxml2.xmlhttp.3.0", "Msxml2.xmlhttp", " Microsoft.XMLHTTP "];
for (var i = httplist.length-1;i >= 0;i--) {
try{
b = new ActiveXObject (httplist[i]);
Ajax.ajax_getobj = function () {
return new ActiveXObject (Httplist[i]);
}
return b;
}catch (ex) {}
}
}else if (window.xmlhttprequest) {//for other
b = new XMLHttpRequest ();
}
Ajax.ajax_getobj = function () {
return new XMLHttpRequest ();
}
return b;
}