更新时间:2022-01-06 03:53:49
增加时间的setTimeout:
setTimeout at an increase time:
$('li').each(function(indexInArray){
var data = $(this).text();
setTimeout( function () {
requestFunction(data, function(status){
if ( status == 'OK' ) do stuff...
});
}, indexInArray * 500);
});
如果你循环遍历这些元素,我们想要增加超时,否则所有请求都会在没有延迟的情况下同时触发,但仅在我们的500毫秒超时后才会触发。
if you loop over these elements, we want to increase the timeout or else all the request would fire at the same time if not delayed, but only after our 500 ms timeout.