I am trying to process and update query for 1000 items at a time. I tired settings cache to false, and even tried setTimeout to have a pause between requests. Each request should take 5-6 seconds and then the process will never timeout, but after 4-5 requests it reaches server execution limit.
The problem is I need to use PHP objects in my update query. every request seems to take longer so it seems the objects are looping in PHP
Is there anyway to stop this happening?
Here is the javascript code
function processIndex() {
$.ajax({
url: responder,
dataType: "json",
data: data,
cache: false,
async: false,
error: function(XMLHttpRequest, textStatus, errorThrown){
// alert('status:' + XMLHttpRequest.status + ', status text: ' + XMLHttpRequest.statusText + ' LIMIT ' + limitFrom + ', ' + limitTo);
limitFrom = limitTo;
limitTo += 1000;
processIndex('indexPrices');
},
success: function(data) {
limitFrom = limitTo;
limitTo += 1000;
setTimeout(function() {
processIndex();
}, 1000);
}
});
}
});
}
You can use http://www.protofunc.com/scripts/jquery/ajaxManager/
OR
https://gist.github.com/2470554
To queue up the ajax requests.
Another way of doing this is to send few records (say 50 records at a time) and loop through them in server side code.
You can combine these 2 solutions to get optimum result