Skip to content

Instantly share code, notes, and snippets.

@keyle
Created March 14, 2014 08:35
Show Gist options
  • Select an option

  • Save keyle/9544102 to your computer and use it in GitHub Desktop.

Select an option

Save keyle/9544102 to your computer and use it in GitHub Desktop.
Simple ajax, pure javascript, no jquery
function callAjax(url, callback){
var xmlhttp;
// compatible with IE7+, Firefox, Chrome, Opera, Safari
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