setInterval interfering with hide()
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
);
精彩评论