Instantly share code, notes, and snippets.

Embed
What would you like to do?
function sendTestLead() {
callAjax("servlet/SendTestLead?order_id=165&product_id=1", alert);
}
function callAjax(url, f) {
var o = new Object();
o.req = makeXMLHttpRequest();
o.req.onreadystatechange = function() {
if(o.req.readyState == 4)
f(o.req.responseText);
}
o.req.open("GET", url, true);
o.req.send("");
}
function makeXMLHttpRequest() {
var req;
// branch for native XMLHttpRequest object
if(window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch(e) {
req = false;
}
// branch for IE/Windows ActiveX version
} else if(window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
req = false;
}
}
}
return req;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment