jQuery, JSON, Progress Bar and PHP...

jQuery, JSON, Progress Bar and PHP...

Dear all,

I am trying to do the following: I have a PHP page with a determined number of loops, however the number of loops is huge. I need to create a progress page with jQuery, AJAX and JSON. Unfortunately, the code that I wrote re-starts the page as it visits it every 1.5 seconds. How will the PHP page update the JSON object on the fly, in order the getJSON part to run appropriately?

The code is:

var i = setInterval(function() { 
$.getJSON("call.php?catId=14417537", function(data) {
if (data == null) {
clearInterval(i);
location.reload(true);
return;
}
alert(data.loop);

});
}, 1500);

Any help please? Thank you very much!