Skip to content

Instantly share code, notes, and snippets.

@jonasdeherdt
Created June 4, 2014 13:28
Show Gist options
  • Save jonasdeherdt/07cf19ba5adae44d9faf to your computer and use it in GitHub Desktop.
Save jonasdeherdt/07cf19ba5adae44d9faf to your computer and use it in GitHub Desktop.
json loader (no name structure)
function loadContent(sources, callback) {
var contents = {};
var loadedContents = 0;
var numContents = 0;
for (var src in sources)
numContents++;
for (var src in sources) {
$.getJSON(sources[src], function(data) {
contents[count] = data;
if (++loadedContents >= numContents) {
callback(contents);
}
count ++;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment