我试过这些:
<div id="result">
<table>
<?php require('newses.php'); ?>
</table>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
function autoRefresh_div()
{
$("#result").load("load.html");// a function which will load data from other file after x seconds
}
setInterval('autoRefresh_div()', 1000); // refresh div after 5 secs
</script>
但它对我不起作用。 请访问这些页面:
Reload the content of a div afer regular interval of time
http://devzone.co.in/automatically-refresh-html-page-div-specific-time-interval/
最佳答案
function autoRefresh_div() {
$("#result").html('<object data="https://static.pexels.com/photos/17679/pexels-photo.jpg"/>'); // a function which will load data from other file after x seconds
alert('working');
}
setInterval(autoRefresh_div, 5000); // refresh div after 5 sec
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="result"></div>
这将每隔 5 次加载页面。
关于javascript - 在特定时间间隔内刷新 PHP 所需的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46277499/