I wrote a simple ajax Connection Library and didn't use jquery's ajax. This code is lighter than jquery. Please refer to it for reference,
The Code is as follows:
Var ajax = {
Init: function (){
Var xmlHttp = new XMLHttpRequest ();
If (! Window. XMLHttpRequest)
XmlHttp = new ActiveXObject ("Microsoft. XMLHTTP ");
Return xmlHttp;
},
Call: function (opt ){
Var xmlHttp = this. init ();
XmlHttp. onreadystatechange = function (){
If (xmlHttp. readyState = 4)
{
XmlHttp. status = 200?
Opt. success (xmlHttp. responseText, xmlHttp. responseXML): opt. error (xmlHttp. responseText, xmlHttp. status );
}
}
Opt. data = this. parseData (opt. data );
If (opt. method. toLowerCase () = 'get '){
Opt. url = opt. url + "? "+ Opt. data;
Opt. data = null;
}
XmlHttp. open (opt. method, opt. url, opt. async );
If (opt. method. toLowerCase () = 'post ')
XmlHttp. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded ");
XmlHttp. send (opt. data );
},
ParseData: function (data ){
If (typeof data = 'object '){
Var str = '';
For (var I in data ){
Str + = "&" + I + "=" + encodeURIComponent (data [I]);
}
Return str. length = 0? Str: str. substring (1 );
} Else {
Return data;
}
}
}