every 5 seconds with setTimeout I'm executing a jQuery function, how can I stop the process by clicking on a div?
my code is:
function crono(selection){
$.ajax({
type: 'GET',
url: 'my_page.php',
data: {
my_page: selection.attr('id')
},
success: function(data, textStatus, jqXHR) {
selection.html(data);
}
});
}
function repeat(){
setTimeout(function() {
$('.toReload').each(function(){
crono($(this));
});
repeat();
}, 5000);
}
repeat();