right now I have an interval function in jquery that reloads a page every few seconds :
setInterval(function () {
$('div#tab2').load('morefour.php?doc=' + encodeURIComponent(ktitle));
}, 3000);
});
What I actually want to do now is if this input is clicked :
<input type='image' class='edit' src='edit.png'>
stop the setinterval function.
setIntervalreturns a handle you can use withclearIntervalto cancel it. The handle will be a number greater than zero.So save the handle from the
setIntervalcall:…and then use it to cancel it if the button is pressed:
Also note in that first snippet above, I’ve moved the interval parameter (
3000) to where it should be (as Jared pointed out, you had it as a second parameter toload, where of course it should be a second parameter tosetInterval).