Skip to content

Instantly share code, notes, and snippets.

@opyate
Created July 17, 2013 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opyate/6020023 to your computer and use it in GitHub Desktop.
Save opyate/6020023 to your computer and use it in GitHub Desktop.
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