Created
April 1, 2016 20:08
-
-
Save pzp1997/373c8573b5978ab82e8dc247632433f1 to your computer and use it in GitHub Desktop.
Uses XMLHttpRequest to make an AJAX get request.
This file contains hidden or 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
var getRequest = function(url, callback) { | |
var xhr = new XMLHttpRequest(); | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState === XMLHttpRequest.DONE) | |
callback(xhr.status === 200 ? xhr.responseText : null); | |
}; | |
xhr.open('GET', url, true); | |
xhr.send(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment