Skip to content

Instantly share code, notes, and snippets.

@kapouer
Created March 12, 2015 15:20
Show Gist options
  • Select an option

  • Save kapouer/5bc81b3533a3d113d4ec to your computer and use it in GitHub Desktop.

Select an option

Save kapouer/5bc81b3533a3d113d4ec to your computer and use it in GitHub Desktop.
function getXml(url, cb) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange = function (e) {
if (xhr.readyState == 4) {
var code = xhr.status;
if (code >= 200 && code < 400) {
cb(null, xhr.responseXML);
} else {
var err = new Error(xhr.responseText);
err.code = code;
cb(err);
}
}
};
xhr.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment