【发布时间】:2015-02-06 14:09:42
【问题描述】:
如何延迟 for 循环,直到函数“some_multi_ajax_function()”更改全局变量(exe_counter 将为 0)?
for (i = 0; i < some_data_list.length; i++) {
exe_counter=1;
if(i>0 && exe_counter != 0){
delay{
// delay for loop until some_multi_ajax_function() set exe_counter = 0
// do not execute second iteration
}
}else{
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;
});
}
【问题讨论】:
-
你的脚本到底应该做什么?
-
按坐标搜索广告,协调从google api获取。并且可以搜索10次
标签: javascript ajax for-loop delay execution