[英]AJAX auto reload table won't execute
我正在嘗試使用 AJAX 自動重新加載腳本每隔幾秒重新加載 PHP 腳本
這是腳本:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.js"></script>
<script>
$(document).ready(function() {
function reload() {
$('#autoload').load('assets/php/get-emails.php');
}
setInterval(reload, 1000);
});
</script>
HTML 表代碼(第):
<table class="table" style="background-color :1c1f20;" id="inbox autoload">
<thead>
<tr style="color: grey;text-align:center;font-weight:bolder;">
<the scope="col"> From </th>
<the scope="col">Title</th>
<the scope="col">details</th>
<the scope="col">forward</th>
</tr>
</thead>
<tbody>
<div>
<?PHP
DisplayEmails($_COOKIE['t_email_address_1']);
?>
</div>
</tbody>
</table>
但它不起作用,我嘗試了我找到的每一個解決方案。
順便說一句:get-emails 打印出來......為一張桌子打上標簽。
並且 autload id 在 table 標簽中。
提前致謝!
html id 只能是一個,不能將收件箱和自動加載分開,html 中的“id”不像 html 類那樣工作。 因此,您可以使用類,也可以只為 id IE“收件箱”或“自動加載”指定一個名稱,但不能同時使用這兩個名稱,充其量您可以像這樣“收件箱-自動加載”加入 id
值得注意:
請使用 jQuery $.on(),如果您想處理加載時 DOM 中以前不存在的自動生成數據或標簽,但它是通過 AJAX 動態加載的(這只是假設,您的自動加載 html 標記,在初始頁面加載時不存在)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.