Skip to content

Instantly share code, notes, and snippets.

@sudheerDev
Created May 8, 2017 04:36
Show Gist options
  • Save sudheerDev/536862e351c819dd52a02d1ea34ef785 to your computer and use it in GitHub Desktop.
Save sudheerDev/536862e351c819dd52a02d1ea34ef785 to your computer and use it in GitHub Desktop.
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