Skip to content

Instantly share code, notes, and snippets.

@joyrexus
Created October 22, 2013 18:08
Show Gist options
  • Save joyrexus/7105202 to your computer and use it in GitHub Desktop.
Save joyrexus/7105202 to your computer and use it in GitHub Desktop.
Load json via xhr
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