![](/img/trans.png)
[英]How to get data from DB (Postgres) in the same order as user input?
[英]How to refresh div in order to get newly incoming data from DB
我正在使用( http://jquerynewsticker.com/ )中的jquery新聞行情欄作為我的頁腳。 頁腳僅加載一次,因此,如果我將新數據添加到數據庫中,則不會顯示新數據。
我希望新聞代碼div本身每x秒刷新一次,因此,如果我的數據庫中有新數據,它將顯示出來。
該新聞報導當前為:
<div class="footer" id="footerticker">
<ul id="js-news" class="js-hidden">
<c:forEach items="${handcarryTicker}" var="handcarry2">
<li class="news-item">
<td>LGP: ${handcarry2.item1}</td>
<td>${handcarry2.item2}</td>
</li>
</c:forEach>
</ul>
</div>
我找到了一些刷新div的解決方案,但不幸的是,它們對我沒有用。 頁腳已加載並顯示3秒鍾,然后消失。 如何修復刷新但不會消失的代碼?
我當前的腳本是:
<script>
function refresh() {
setInterval(() => {
$('#footerticker').load(document.URL + ' #footerticker')
}, 3000);
}
$(document).ready(refresh);
</script>
setInterval
的第一個參數應該是您要每3000毫秒執行一次的函數。 在您的示例中, update
不是已定義的函數。
您可能想要的是這樣的東西:
<script>
function refresh() {
setInterval(() => {
$('#footerticker').load(document.URL + ' #footerticker')
}, 3000);
}
$(document).ready(refresh);
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.