当调用重新加载页面的setTimeout函数时,timeago.js会一直闪烁... [英] The timeago.js keeps flickering when the setTimeout function of reloading the page is called...

查看:63
本文介绍了当调用重新加载页面的setTimeout函数时,timeago.js会一直闪烁...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小型社交网站,它有一个墙,显示所有用户帖子。 wall中包含此功能

I have a small social website, and it has a "wall" where all user posts are shown. The "wall" has this function in it

<script>$(function load_posts(){  $("#all_posts").load("/all_posts.php")
setTimeout(load_posts, 500);})</script>
<div id="all_posts"></div>



其中all_posts.php显示所有帖子。但是每个帖子都有一个日期和timeago.js,所以它显示帖子2小时前等。

但是当调用该函数并重新加载all_posts.php时,闪烁的时间为第二,然后消失...有谁知道为什么这是我怎么解决它?


Where "all_posts.php" shows all of the posts. However each posts has a date and the timeago.js with it so it displays "posts 2 hours ago" etc.
But when the function is called and the all_posts.php is reloaded the time flashes for a second then disappears...does anyone know why this is and how i could fix it?

推荐答案

(function load_posts(){
(function load_posts(){


(#all_posts)。load(/ all_posts.php)
setTimeout(load_posts,500);})< / script >
< div id = all_posts > < / div >
("#all_posts").load("/all_posts.php") setTimeout(load_posts, 500);})</script> <div id="all_posts"></div>



其中all_posts.php显示了所有帖子。但是每个帖子都有一个日期和timeago.js,所以它显示帖子2小时前等。

但是当调用该函数并重新加载all_posts.php时,闪烁的时间为第二个然后消失...有谁知道为什么这是我以及如何解决它?


Where "all_posts.php" shows all of the posts. However each posts has a date and the timeago.js with it so it displays "posts 2 hours ago" etc.
But when the function is called and the all_posts.php is reloaded the time flashes for a second then disappears...does anyone know why this is and how i could fix it?


这篇关于当调用重新加载页面的setTimeout函数时,timeago.js会一直闪烁...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆