问题描述
我希望我的网页上有一个DIV在10分钟后自动刷新。我不想重新加载整个页面,只是一部分。
I would like one DIV on my page to automatically refresh after 10 minutes. I don't want to reload the entire page, just the one part.
这是我使用的PHP:
function fblikes() {
$pageID = $_GET['id'];
$pagename = json_decode(file_get_contents('http://graph.facebook.com/' . $pageID));
echo $pagelikes->likes;
}
这就是我想要自动刷新的内容:
And this is what I want to be refreshed automatically:
<div>
<span><?php fblikes(); ?></span>
</div>
有人可以帮我吗?
Can somebody help me with this please?
推荐答案
:
您需要编写一些JavaScript代码,使用 setTimeout
分钟,然后使用Ajax调用来检索JSON或HTML数据,然后将其解析或放入相关的 span
元素中。
You need to write some Javascript, use setTimeout
to schedule a function for execution in 10 minutes, and then use an Ajax call to retrieve JSON or HTML data that is then either parsed or placed in the relevant span
element.
在您特定的情况下,您可以通过使用Facebook客户端Javascript API来让自己的生活更轻松,只需发出 FB.api(...)
打电话每10分钟一次,因为这似乎是你想要的。
In your very specific situation you can make your own life easier by using the Facebook clientside Javascript API, and just issue a FB.api(...)
call every 10 minutes since that appears to be what you want.
这篇关于10分钟后自动刷新DIV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!