Reputation: 997
I have some Order ids and each order id having some product requests. When user selects the order ids and click on start process button i am comparing the product requests with available stocks and displaying final result after completion of the process. Final out put is some thing like order id, related product request, available stock and if there was no stock then i am displaying not available for that order id. Everything fine.
But my new requirement is suppose if i have 100 order ids, system start process the first order id once its completes then output will display ,next 2nd order id after completion of process related output, this should append to the first result and so on..
How can i achieve this?*
Means one side script is executing and other side related out put will display. How it is possible by using php and jQuery? Any idea would be greatly appreciated.
Upvotes: 0
Views: 125
Reputation: 11750
If I understood correctly, you want to load every order id related info in sequence and not all at once.
Suppose there is an array that holds all the order ids you want to load:
var orders = [1,2,3,...,100];
Start by loading the first one:
// Here we execute 1 ajax call for each order
// (I think you should load more than 1 order info per ajax call.
// You could load a set of, lets say, 10 orders at a time, it's up to you)
var counter = 0;
loadSet(orders[counter]);
function loadSet(orderID) {
// Increase counter by 1
counter++;
// Execute ajax call
$.ajax({
url: '...',
data: { orderID: orderID },
success: function(data) {
// Append data after the previously loaded results
$('#resultsHolder').append(data);
// Load next set if there are unloaded orders in the array
if (orders[counter]) {
loadSet(orders[counter]);
}
},
error: function() {
// Error handling...
}
});
}
Upvotes: 1