开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜