Created
April 13, 2016 19:30
-
-
Save himynameisdave/78ed918f5c8d479cdba44b7d2cf56fb2 to your computer and use it in GitHub Desktop.
Simple XMLHttpRequest wrapper
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
| 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