大家好
我对同一个函数调用了9次。不幸的是,它看起来运行得如此之快,以至于一些函数没有完成或被调用
loadpaymentboxes('1t1', '1h1', p1t1, p1i1);
loadpaymentboxes('1t2', '1h2', p1t2, p1i2);
loadpaymentboxes('1t3', '1h3', p1t3, p1i3);
loadpaymentboxes('2t1', '2h1', p2t1, p2i1);
loadpaymentboxes('2t2', '2h2', p2t2, p2i2);
loadpaymentboxes('2t3', '2h3', p2t3, p2i3);
loadpaymentboxes('3t1', '3h1', p3t1, p3i1);
loadpaymentboxes('3t2', '3h2', p3t2, p3i2);
loadpaymentboxes('3t3', '3h3', p3t3, p3i3);
如何将这些调用链接起来,以便只有在前一个调用完成后,才允许再次运行它。
此代码将在一秒钟后执行函数
var i = 1;
var timer = setInterval(function() {
if( i >= 9 ) {
clearInterval( timer );
}
//YourFunction();
console.log(i);
i++;
}, 1000/*Change this time in milliseconds to modify the execution time between functions*/);