开发者

setInterval interfering with hide()

开发者 https://www.devze.com 2023-03-03 01:50 出处:网络
I recently implemented a loading image and noticed that ever 10 seconds, that the loading image appears for a split second then disappears again. I\'ve traced it to this code. When I comment this out,

I recently implemented a loading image and noticed that ever 10 seconds, that the loading image appears for a split second then disappears again. I've traced it to this code. When I comment this out, the loading image never 开发者_StackOverflow社区appears until it is supposed to. I'm using the setInterval code globally so is there something that I can do to get these two things working nicely together?

I want to stop the loading image from appearing for a brief second.

  var auto_refresh = setInterval(
    function() {
      ....
    }, 10000
  );


Not sure what you ask, if you mean execute it only once then change the code to setTimeout instead:

var auto_refresh = window.setTimeout(
    function() {
      ....
    }, 10000);


If you don't want the event to be triggered periodically, you should look at setTimeout instead. It only fires once.

  var auto_refresh = setTimeout(
    function() {
      ....
    }, 10000
  );
0

精彩评论

暂无评论...
验证码 换一张
取 消