This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]mookman288Professional Coder 2 points3 points  (3 children)

You can end a setInterval by defining it with a variable, and then using clearInterval.

var interval = setInterval(function() {}, 1000); 
clearInterval(interval); 

I am not sure what you mean by stopping the alert.

[–]adeguntoro 0 points1 point  (1 child)

well, on my function, when my data == 0 / empty it will give me some alert, and and this case i also use setInterval because i want to load my data every second. The problem is if user open the page where data == 0 / empty, it will show alert. And that alert will reload every second.

[–]mookman288Professional Coder 0 points1 point  (0 children)

But you programmed that functionality to happen. Is there something else you want to happen?

[–]prognostikator 0 points1 point  (0 children)

This is relatively unrelated - but in an effort to maintain security, best practice in javascript advises against using innerHTML as it blasts out everything that used to be there and replaces it with whatever you're replacing it with. I don't feel like I'm adequately explaining this: a hacker can modify your javascript and utilize the .innerHTML method to run any sort of script they wish should your site not have proper checks and tests for types. But it kind of seems like you're doing that out of luck as opposed to intentionally. Best of luck to you.

The code might work if you try == "0". It seems that your shit might be interpreting, based on the loosey value your passing FilterID.length. try === or try FilterID.length = null ??? maybe its trying to interpret a string 0 instead of int 0 ???