Reputation: 39
I am using the following script to refresh a div once every minute.
var auto_refresh = setInterval(
function() { $('#posting').load('posts.php').fadeIn("slow"); }, 60000);
It works great, just as it should. My question is, is there a way that I can cancel that refresh when a user clicks on a particular link on the site. I have a comments section and when they click on View More Comments, i'd like for the site to not auto refresh anymore since that will mess up what they are looking at.
Upvotes: 1
Views: 399
Reputation: 11435
Assuming the link on the site has access to your auto_refresh
variable.
// a link to clik
$('a').click(function (e) {
e.preventDefault();
clearInterval(auto_refresh);
});
Upvotes: 0