【发布时间】:2025-12-18 03:20:10
【问题描述】:
我正在尝试在 div 中调用另一个名为 bidtable.php 的页面,我希望它每 20 秒刷新一次。这是我尝试过的方法,但它不起作用。
<script src="http://code.jquery.com/jquery-latest.js"></script>
<div class="row justify-content-center">
<div id="latestData" class="row justify-content-center col-md-5" style="background-color: black; margin: 2px auto; width: 370px;"></div>
</div>
$(document).ready(function() {
refreshTable();
});
function refreshTable() {
$('#latestData').load('bidtable.php', function() {
setTimeout(refreshTable, 20000);
});
}
【问题讨论】:
-
首先检查控制台是否存在 AJAX 请求错误。其次,请注意 AJAX 轮询不是可扩展的解决方案。如果您需要保持客户端和服务器端紧密同步,请使用 Websockets。
-
如果您使用现代浏览器,它可能会被 CORS 策略阻止。检查您的控制台。是吗?
-
实际上,当我用我的 localhost/phpmyadmin 品尝它时,它运行良好,但现在该网站已上线,但无法正常工作。你能建议我解决这个问题的任何其他想法吗?请。
-
这能回答你的问题吗? How to load PHP file into DIV by jQuery?
标签: javascript jquery html