使用php每10秒刷新一次div或函数数据

使用php每10秒刷新一次div或函数数据,php,html,Php,Html,我希望每10秒刷新一次通知计数 请尝试此代码 <div id="sample">Testing refresh every 5 seconds</div> I would take a look at this below as well, although it may not be relevant in your case. http://stackoverflow.com/questions/729921/settimeout-or-setinterva

我希望每10秒刷新一次通知计数


请尝试此代码

<div id="sample">Testing refresh every 5 seconds</div>

 I would take a look at this below as well, although it may not be relevant in your case.

http://stackoverflow.com/questions/729921/settimeout-or-setinterval

你不能用php实现这一点。但是您可以在js中设置
setInterval
,每n秒请求一次。如果你想每n分钟使用一次。你可以使用
cronjobs
。看。这能回答你的问题吗?
$(document).ready(
function() {
  setInterval(function() {
     var someval = Math.floor(Math.random() * 100);
     $('#sample').text('Test' + someval);
  }, 10000);  //Delay here = 10 seconds 
});