I have 2 questions:
1- How do I set a delay when an ajax post is executing many times ?
2 -How to run some_multi_ajax_function() when the variable exe_counter reaches 0 ?
here is my code:
for (i = 0; i < some_data_list.length; i++) {
exe_counter=1;
data = some_data_list[i];
// Many ajax posts will be executed here. In the end exe_counter will be set to 0;
some_multi_ajax_function(data);
}
function some_multi_ajax_function(data){
$.ajax({
...
}.done(function(d) {
// here it could be used another ajax function
exe_counter = 0;
});
}
UPDATE
I am sorry, I have bad explained. I want execute
data = some_data_list[1]; // second iteration. after that and others
some_big_function(data); // this can't start if exe_counter != 0
when exe_counter==0 its mean that some_multi_ajax_function() is completely done.