gpt4 book ai didi

javascript - 每 x 秒自动刷新 div 并停止成功加载

转载 作者:行者123 更新时间:2023-11-28 07:56:11 24 4
gpt4 key购买 nike

我需要创建一个每 10 秒自动刷新一次的 div,并在成功加载时停止。我创建了这个 jQuery 脚本:

<script type="text/javascript">
$(document).ready(function(){
var j = jQuery.noConflict();
j(document).ready(function()
{
j(".refresh").everyTime(1000,function(i){
j.ajax({
url: "pin.php",
cache: false,
success: function(html){
j(".refresh").html(html);
}
})
})
});
j('.refresh');
});
</script>

它可以工作,但是每 10 秒就会刷新一次。如果 pin.php 返回数字输出,我需要它停止。

如果 pin.php 返回数字输出,如何编辑它以停止刷新?

最佳答案

来自 http://www.jquery-plugins.info/jquery-timers-00013992.htm 的文档,您需要的函数可能是 stopTime。虽然我还没有测试过,但您的成功中的以下内容应该有效:

success: function(html) {
if (j.isNumeric(html)) {
j(".refresh").stopTime();
} else {
j(".refresh").html(html);
}
}

关于javascript - 每 x 秒自动刷新 div 并停止成功加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26059293/

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