Is there anyone know how to kill interval after using setInterval()
in the following use case?
Thanks in advance!
$(document).ready(function(){
setInterval(function(){
$.ajax({ url: "test.php",
success: function(result){
$("#results").append(result);
}
});
}, 1000);
});
test.php
$CT = date('Y-m-d H:i:s', time());
echo $CT;
You need to use the clearInterval
function
var interval = setInterval()....
clearInterval(interval);
http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/
var interval = setInterval(function() {
$.ajax({
url: "test.php",
success: function(result) {
$("#results").append(result);
}
});
}, 1000);
clearInterval(interval);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With