Skip to content

Instantly share code, notes, and snippets.

@kypflug
Last active May 26, 2016 17:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kypflug/f486046ba87076088742212316d0df7d to your computer and use it in GitHub Desktop.
Save kypflug/f486046ba87076088742212316d0df7d to your computer and use it in GitHub Desktop.
Making a request for a JSON resource with XHR
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();
@felquis
Copy link

felquis commented May 26, 2016

Meh ¯\_(ツ)_/¯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment