Skip to content

Instantly share code, notes, and snippets.

@gpiffault
Last active September 14, 2017 12:23
Show Gist options
  • Save gpiffault/cb115708f77dd43b79e6 to your computer and use it in GitHub Desktop.
Save gpiffault/cb115708f77dd43b79e6 to your computer and use it in GitHub Desktop.
Vanilla xhr
function xhr(options, success) {
var r = new XMLHttpRequest();
r.open(options.method || "GET", options.url, true);
r.onreadystatechange = function () {
if (r.readyState != 4 || r.status != 200) return;
success(r.responseText, r);
};
r.send(options.data || null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment