Skip to content

Instantly share code, notes, and snippets.

@funkjedi
Created May 30, 2013 02:07
Show Gist options
  • Save funkjedi/5675336 to your computer and use it in GitHub Desktop.
Save funkjedi/5675336 to your computer and use it in GitHub Desktop.
Super simple super tiny ajax function
function xhr(url, post) {
var req = window.ActiveXObject
? new ActiveXObject('Microsoft.XMLHTTP')
: new XMLHttpRequest();
if (post) {
req.open("POST", url, true);
req.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
req.setRequestHeader('Connection', 'close');
req.send(post);
return;
}
req.open("GET", url, true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment