Skip to content

Instantly share code, notes, and snippets.

@btk
Created May 21, 2016 17:33
Show Gist options
  • Save btk/73e8de6e12a73ae0c0e44bc421ab9eb1 to your computer and use it in GitHub Desktop.
Save btk/73e8de6e12a73ae0c0e44bc421ab9eb1 to your computer and use it in GitHub Desktop.
var getJSON = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open("get", url, true);
xhr.responseType = "json";
xhr.onload = function() {
var status = xhr.status;
if (status == 200) {
callback(null, xhr.response);
} else {
callback(status);
}
};
xhr.send();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment