Last active
August 17, 2016 06:08
-
-
Save robbestad/6d041f7d57f8e01f09fd32162c2f04e0 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
| var get = function (path, callback) { | |
| var request = new XMLHttpRequest(); | |
| request.onreadystatechange = function () { | |
| if (request.readyState == 4) { | |
| if (request.status === 200) { | |
| callback(JSON.parse(request.responseText)); | |
| } else { | |
| console.error("Error", request.statusText); | |
| } | |
| } | |
| }; | |
| request.open('GET', path); | |
| request.send(); | |
| }; | |
| console.time('get'); | |
| get('//jspromises.herokuapp.com/search/promises', function (response) { | |
| document.querySelector('.results').innerHTML = response.results[0].text; | |
| console.timeEnd('get'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment