Skip to content

Instantly share code, notes, and snippets.

@morningtoast
Created August 23, 2013 18:42
Show Gist options
  • Select an option

  • Save morningtoast/6322641 to your computer and use it in GitHub Desktop.

Select an option

Save morningtoast/6322641 to your computer and use it in GitHub Desktop.
Vanilla ajax
function ajax(url, callback) {
var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { callback(xmlhttp.responseText); }
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment