I have a for loop that loops a bunch of times (1-1000+). In that loop, i'm calling an ajax page to do some database stuff. I need a way to tell when the last item is done so i can refresh the page. What i did was run the loop and db code and right after do a refresh of the page, but what's happening, is a lot of the requests aren't done because it seems it's refreshing before some db updates are applied. How do i do this? Here's my code:
for (i = 0; i < acIDs.length; i++) {
var acID = acIDs[i];
$.get('/ajax/db.asp?clientID=123&action=batchEditA&batchFieldA='+batchFieldA+'&batchValueA='+escape(batchValueA)+'&acID='+acID+'&pos='+pos);
}
location.reload(true);