Created
July 15, 2017 21:45
-
-
Save Chalarangelo/808c5d0558ce79d6c813819ce8998356 to your computer and use it in GitHub Desktop.
AJAX GET request function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Send a 'GET' request to the specified url and run the callback function when it completes. | |
function httpGetAsync(url, callback) { | |
var xmlHttp = new XMLHttpRequest(); | |
xmlHttp.onreadystatechange = function() { | |
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) | |
callback(xmlHttp.responseText); | |
}; | |
xmlHttp.open('GET', url, true); | |
xmlHttp.send(null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment