var Ajax = function (o) {
/*
* @ O. URL request URL
* @ O. method set to post or get
* @ O. async set async or not
* @ O. data parameters to be sending
* @ O. success callback function for success
* @ O. fail callback function for fail
* @ O. header Set Request HTTP herder
* @ O. user set username
* @ O. PWD set password
*/
var xhr = Window. XMLHttpRequest? New XMLHttpRequest (): New activexobject ("Microsoft. XMLHTTP");
var DATA = NULL;
var url = O. url;
If (! O. Data) O. Data ={};
O. Data ['nocache'] = math. Random ();
VaR temp = [];
For (var I in O. Data) temp. Push (I + "=" + O. Data [I]);
Data = temp. Join ("&");
If (! O. Method) O. method = 'get ';
If (O. Method = "get" & Data! = NULL ){
Url = URL + (/\? /. Test (URL )? '&':'? ') + Data;
Data = NULL
}
Xhr. Open (O. method, URL, O. async | true, O. User | '', O. pwd | '');
If (O. header ){
For (VAR type in O. header ){
Xhr. setRequestHeader (type, O. header [type]);
}
}
If (! O. header |! O. header ['content-type']) xhr. setRequestHeader ('content-type', 'application/X-WWW-form-urlencoded ');
Xhr. onreadystatechange = function (){
If (xhr. readystate = 4 ){
If (xhr. Status = 200 | xhr. Status = 206 ){
If (O. Success) {o. Success. Apply (xhr, [xhr. responsetext]);}
} Else {
If (O. Fail) {o. Fail. Apply (xhr );}
}
}
};
Xhr. Send (data );
};
Ajax ({
URL: "draw.html ",
Method: "Get ",
Async: "true ",
Data: {"url": "test", "SGG": "kktest "},
Header :{
'Content-type': 'application/X-WWW-form-urlencoded; charset = UTF-8 ',
'Range': 'bytes = 0-2'
},
Success: function (RET ){
Alert (RET );
Alert (this. getAllResponseHeaders ());
},
Fail: function (){
Alert (this. status );
}
});