开发者

refresh timespan using jquery

开发者 https://www.devze.com 2023-02-10 01:01 出处:网络
I have a page in php which displays timespan like, created10 Minutes 23 Seconds ago I want to update it automatically , without page reloads, so that the seconds , minutes changes dynamically. I 开

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

精彩评论

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