Skip to content

Instantly share code, notes, and snippets.

@segdeha
Last active September 26, 2015 23:57
Show Gist options
  • Save segdeha/1178876 to your computer and use it in GitHub Desktop.
Save segdeha/1178876 to your computer and use it in GitHub Desktop.
Simplest possible Ajax implementation
function ajax(url, callback) {
var xhr;
xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onreadystatechange = function () {
if (4 === xhr.readyState && 400 > xhr.status) {
callback(xhr);
}
};
xhr.send(null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment