Created
October 22, 2013 18:08
-
-
Save joyrexus/7105202 to your computer and use it in GitHub Desktop.
Load json via xhr
This file contains 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
load = (path, done) -> | |
xhr = new XMLHttpRequest() | |
xhr.onreadystatechange = -> | |
if (xhr.readyState is 4) and (xhr.status is 200) | |
done JSON.parse(xhr.responseText) | |
xhr.open("GET", path, true) | |
xhr.send() | |
load 'data.json', console.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment