![](/img/trans.png)
[英]Can I update (not replace content) contents inside the jsp div tag from ajax call
[英]jsp div content not refreshing from js call
jsp代碼:
<div id="myRefreshKBD">
Current Time :<%= new java.util.Date() %>
</div>
JavaScript代碼:
$(document).ready(
function() {
setInterval(function() {
$('#myRefreshKBD').html('I am getting refreshed every 3 seconds..');
}, 3000);
});
我的問題是每當從js刷新myRefreshKBD id時,日期都應刷新...期待一個不錯的答案。 現在很粘。
代碼很好,您只需要像這樣添加jquery庫即可。
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
並且您需要像這樣更改您的javascript
$(document).ready(
function() {
setInterval(function() {
$('#myRefreshKBD').html('Current Time : '+new Date());
}, 3000);
});
jQuery使用“ $”作為“ jQuery”的快捷方式。因此,如果要不下載而使用jQuery,請使用上面的一個,也可以下載並將其添加到項目中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.