gpt4 book ai didi

javascript - 在 JavaScript 中每 N 秒调用一次异步函数

转载 作者:数据小太阳 更新时间:2023-10-29 05:13:35 26 4
gpt4 key购买 nike

<分区>

我有一个需要未定义时间才能完成的 Java Script 函数。在一个循环中,我想等到函数完成,然后等待定义的时间(例如 5000 毫秒)并再次调用该函数。我如何在 Java Script 中完成此操作?

基本上我想要这个:

call function and wait until it is finished
wait another 5000 seconds
call function and wait until it is finished
wait another 5000 seconds
...

函数本身看起来像这样:

for every group in list

.ajax(delete group items; get group items; add group items)

我目前遇到的问题是,在循环的中间,函数以某种方式再次被调用。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com