Skip to content

Instantly share code, notes, and snippets.

@himynameisdave
Created April 13, 2016 19:30
Show Gist options
  • Select an option

  • Save himynameisdave/78ed918f5c8d479cdba44b7d2cf56fb2 to your computer and use it in GitHub Desktop.

Select an option

Save himynameisdave/78ed918f5c8d479cdba44b7d2cf56fb2 to your computer and use it in GitHub Desktop.
Simple XMLHttpRequest wrapper
var req = function (url, cb) {
var r = new XMLHttpRequest();
r.onreadystatechange = function () {
if (r.readyState === 4 && r.statusCode === 200) {
cb(JSON.parse(r.responseText));
}
};
r.open("GET", url, true);
r.send();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment