Last active
December 15, 2015 22:49
-
-
Save michd/5335963 to your computer and use it in GitHub Desktop.
Load JSON file as data in vanilla JS
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
loadJSON({ | |
"lorem": "Lorem ipsum dolor sit amet", | |
"consectetur": "adipisicing elit, laboris, adipisicing dolores nulla tempore cupidatat" | |
}); |
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
(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