gpt4 book ai didi

jquery - setTimeout 在服务器上不起作用

转载 作者:行者123 更新时间:2023-12-01 05:41:05 28 4
gpt4 key购买 nike

我使用Ajax从数据库获取数据,并使用setTimeout延迟数据显示。但在我的电脑中,我使用Wamp。它可以延迟数据显示。但是,当我将文件上传到服务器时。数据不延迟显示。发生了什么?

这是示例代码。

$.getJSON('xxx.php',{'xxx' : xxx},function(data)
{
$.each(data,function(key, val)
{
setTimeout(function()
{
$.getJSON('xxx.php',{'xxx' : xxx},function(data)
{
//show data.
});
},key*450);
});
});

最佳答案

这对我来说看起来不错。值得检查 data 是否为数组,在这种情况下,key 第一个元素将为 0,这意味着 key*450 ,超时0ms。

jQuery documentation关于 $.each 的第二个回调参数:

Type: Function( Integer index, Element element )

关于jquery - setTimeout 在服务器上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30681961/

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