Skip to content

Instantly share code, notes, and snippets.

@aaronbjork
Forked from segdeha/simple-ajax.js
Created January 22, 2013 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aaronbjork/4595373 to your computer and use it in GitHub Desktop.
Save aaronbjork/4595373 to your computer and use it in GitHub Desktop.
function ajax(url, callback) {
var xhr;
xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onreadystatechange = function () {
if (4 === xhr.readyState && 200 === xhr.status) {
callback(xhr);
}
};
xhr.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment