I need to exit from a running interval if the conditions are correct:
JavaScript
x
7
1
var refreshId = setInterval(function() {
2
var properID = CheckReload();
3
if (properID > 0) {
4
<--- exit from the loop--->
5
}
6
}, 10000);
7
Advertisement
Answer
Use clearInterval:
JavaScript
1
7
1
var refreshId = setInterval(function() {
2
var properID = CheckReload();
3
if (properID > 0) {
4
clearInterval(refreshId);
5
}
6
}, 10000);
7