ajax complete does trigger when not complete
I'm using ajax to update a list of articles. On the page is the list of articles, onload there is a loop through the array of articles. For each a ajax update request is called (to prevent PHP timing out). When complete, behind the article's name, 'updated' is shown.
This all works, but really really fast! Way too fast. I build this in Mootools before and it took for 1000 items re-rendering about 0.5 hour, while now its a split second. Instantly behind all the articles it shows 'updated'. When I want to check for the results in the database, PHPmyAdmin is still frozen. So I think the processing is still going on.
Maybe I am using the wrong script for this:
-
var PI_jQuery = jQuery.noConflict();
PI_jQuery(document).ready(function() {
for (i = 0; i < pi_array_items.length; i++){
ajax_url = 'index.php?update_id='+pi_array_items[i];
var items_td_id = 'item_'+pi_array_items[i];
PI_jQuery.ajax({
type: "GET",
url: ajax_url,
complete: show_update(items_td_id)
});
}
});
function show_update(items_td_id){
document.getElementById(items_td_id).innerHTML = 'updated';
progress_bar();
}