Created
March 12, 2015 15:20
-
-
Save kapouer/5bc81b3533a3d113d4ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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