Wednesday, 11 September 2013

.getJSON request not ready after .done is called

.getJSON request not ready after .done is called

I am loading a 100k JSON file - it seems that even though I set the
'usersJSON' variable from a done function, the file has not in fact fully
load. Firefox always fails and the console logs '{"readystate:1"}" - of
course, what's needed here is 4.
Chrome does better but occasionally fails also. Smaller test files load
perfectly. Anyone got any ideas here?
users.init();
users = {
usersJSON:"",
init:function() {
$.getJSON("userJSON.json",function() {
}).done(function(data) {
users.usersJSON=data;
});
users.processUsers()
},
processUsers:function() {
var thisLog=JSON.stringify(users.usersJSON);
console.log(thisLog);
}
}

No comments:

Post a Comment