Skip to content

Instantly share code, notes, and snippets.

@lmccart
Created October 22, 2013 18:33
Show Gist options
  • Save lmccart/7105670 to your computer and use it in GitHub Desktop.
Save lmccart/7105670 to your computer and use it in GitHub Desktop.
exports.loadJSON = function(file, callback) {
var req = new XMLHttpRequest();
req.overrideMimeType('application/json');
req.open('GET', 'data/'+file);
req.onreadystatechange = function () {
if(req.readyState === 4) {
if(req.status === 200 || req.status == 0) {
if (typeof callback !== 'undefined') callback();
console.log(req.responseText);
return JSON.parse(req.responseText);
}
}
}
req.send(null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment