Created
June 4, 2014 13:28
-
-
Save jonasdeherdt/07cf19ba5adae44d9faf to your computer and use it in GitHub Desktop.
json loader (no name structure)
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 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