Javascript 每5秒自动刷新一次DIV代码不工作
朋友 我有下面的代码来刷新下面的DIV id refreshDiv,以便每5秒自动刷新一次,但它不起作用Javascript 每5秒自动刷新一次DIV代码不工作,javascript,ajax,jquery,Javascript,Ajax,Jquery,朋友 我有下面的代码来刷新下面的DIV id refreshDiv,以便每5秒自动刷新一次,但它不起作用 <div id ="refreshDiv" class="span2" style="text-align:left;"> <c:set var="map" value="${alertStatusForm.channelStateForRecipients[currentChannel]}"></c:set> <div> <labe
<div id ="refreshDiv" class="span2" style="text-align:left;">
<c:set var="map" value="${alertStatusForm.channelStateForRecipients[currentChannel]}"></c:set>
<div>
<label><img src="${channelIcon}">
${fn:length(map['DELIVERED'])}</label>
</div>
<div>
<label><img src="${channelIcon}">
${fn:length(map['FAILED'])}</label>
</div>
<div>
<label><img src="${channelIcon}">
${fn:length(map['IN_PROGRESS'])}</label>
</div>
</div>
function refreshDiv(){
$.ajax({
url: 'editReg.jsp'
}).done(function(result) {
$('#refreshDIV').text(result);
});
}
${fn:length(映射['DELIVERED']])}
${fn:length(映射['FAILED'])}
${fn:length(映射['正在进行])}
函数refreshDiv(){
$.ajax({
url:'editReg.jsp'
}).完成(功能(结果){
$('#refreshDIV')。文本(结果);
});
}
您没有调用refreshDiv()
。你刚刚定义了它。加载dom时调用此函数,并使用setTimeout
在每5秒后继续调用
$(function(){
function refreshDiv(){
$.ajax({
url: 'editReg.jsp'
}).done(function(result) {
$('#refreshDIV').text(result);
window.setTimeout(refreshDiv, 5000);
});
}
window.setTimeout(refreshDiv, 5000);
});
你不需要
setInterval
吗?没有人调用函数refreshDIV