refresh timespan using jquery
I have a page in php which displays timespan like,
created 10 Minutes 23 Seconds ago
I want to update it automatically , without page reloads, so that the seconds , minutes changes dynamically. I 开发者_开发技巧can put that in a separate div if needed..
Thanks
You con use jquery countdown plugin. Here is example.
You could try something like this. Every 10 seconds its called.
function getTime(){
$.ajax({
url: 'time.php',
success: function(data) {
$('#timeElement').html(data);
setTimeout(function(){getTime();}, 10000);
}
});
}
getTime();
精彩评论