-
-
Save kypflug/f486046ba87076088742212316d0df7d to your computer and use it in GitHub Desktop.
Making a request for a JSON resource with XHR
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
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', url); | |
xhr.responseType = 'json'; | |
xhr.onload = function() { | |
console.log(xhr.response); | |
}; | |
xhr.onerror = function() { | |
console.log("Houston, we've got a problem."); | |
}; | |
xhr.send(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Meh
¯\_(ツ)_/¯