Reputation: 673
I am not sure I am doing this correctly. Basically, my Jquery script calls a 500kb json file and loads it into an array, after that is done the rest of the page loads.
The first request happens fine, but if I refresh the browser it gets slower each time until eventually it is completely sluggish. What's more is that it seems the whole server might be affected because I cannot upload via FTP either until I wait a little bit.
Any thoughts/help would be much appreciated. There is really nothing else running. If I remove this block then the page loads fine.
var content = array[];
function getData() {
//loader with progress bar - load 500kb json file
$.getJSON('lib/soundCloudData.json', function(data){
$.each(data, function (index, item) {
content.push(item);
});
//remove loader and get main page
runSetup()
});
}
Upvotes: 0
Views: 140
Reputation: 79
just a guess,
your 500 KB JSON file takes a while in loading (while means in milliseconds), but it's asynchronous method (it keeps running while the control moves on).
so basically you are calling your runsetup() method while the data is not ready, may be that is causing the problem.
try using a callback for getJSON method and inside that call back run your setup method.
Upvotes: 1