Skip to content

Instantly share code, notes, and snippets.

@michd
Last active December 15, 2015 22:49
Show Gist options
  • Save michd/5335963 to your computer and use it in GitHub Desktop.
Save michd/5335963 to your computer and use it in GitHub Desktop.
Load JSON file as data in vanilla JS
loadJSON({
"lorem": "Lorem ipsum dolor sit amet",
"consectetur": "adipisicing elit, laboris, adipisicing dolores nulla tempore cupidatat"
});
(function (window) {
function somePostLoadCallBack(data) {
// Do what you need to do with your newly parsed data
}
window.loadJSON = function (data) {
somepostLoadCallBack(JSON.parse(data));
}
}(this));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment