Is there any real advantage to using the jQuery AJAX function over the type of AJAX function shown below? Obviously, the syntax is a little cleaner / shorter - but is there any noticiable difference that would justify re-writing my existing ajax code?
var ajax = getXmlObject();
var url= '/addPartToCart.php?m=' + encodeURIComponent(m) +
'&q=' + qty +
'&refresh=' + randomString();
if (ajax.readyState == 4 || ajax.readyState == 0) {
ajax.open("POST", url, true);
ajax.onreadystatechange = function (){
if (ajax.readyState == 4) {
}
};
ajax.send(null);
}
function getXmlObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
//error
}
}
UPDATE
I've reprogrammed all of my AJAX functions to use jQuery's .ajax(). I must say I've seen a notable improvement in speed and reliability.
url += '&formJSON='+ encodeURIComponent(serializedFormString);