您可以使用javascript setInterval();
<script>
$(document).ready(function(){
setInterval(function(){ reload_page(); },60*60000);
});
function reload_page()
{
window.location.reload(true);
}
</script>
试试这个:
<?php
$page = $_SERVER['PHP_SELF'];
$sec = "3600";
?>
<html>
<head>
<meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'">
参考这个答案https://stackoverflow.com/a/19807718/6390490
使用 HTML Meta 标记每 300 秒刷新一次文档
编辑:对于背景,你必须使用像这样的ajaxhttps://stackoverflow.com/a/25446696/6390490
function loadlink(){
$('#links').load('test.php',function () {
$(this).unwrap();
});
}
loadlink(); // This will run on page load
setInterval(function(){
loadlink() // this will run after every 5 seconds
}, 5000);
供服务器端刷新使用
header("Refresh: 300;url='http://thepage.com/example'");//set time here as per your need
setTimeout(function reloadData() {
location.reload();
},60000*60);