1

朋友们

我有以下代码来刷新以下 DIV id refreshDiv 以每 5 秒自动刷新一次,但它不起作用

<div id ="refreshDiv" class="span2" style="text-align:left;">
  <c:set var="map" value="${alertStatusForm.channelStateForRecipients[currentChannel]}"></c:set>
<div>
<label><img src="${channelIcon}">&nbsp;
  ${fn:length(map['DELIVERED'])}</label>
 </div>
 <div>
 <label><img src="${channelIcon}">&nbsp;
  ${fn:length(map['FAILED'])}</label>
 </div>
 <div>
<label><img src="${channelIcon}">&nbsp;
${fn:length(map['IN_PROGRESS'])}</label>
</div>
</div>

function refreshDiv(){
     $.ajax({
        url: 'editReg.jsp'
    }).done(function(result) {
        $('#refreshDIV').text(result);
    });
}
4

1 回答 1

3

你没有打电话refreshDiv()。你刚刚定义了它。在加载 dom 时调用此函数,并在每 5 秒后使用setTimeout.

$(function(){
    function refreshDiv(){
        $.ajax({
            url: 'editReg.jsp'
        }).done(function(result) {
            $('#refreshDIV').text(result);
            window.setTimeout(refreshDiv, 5000);
        });

    }
    window.setTimeout(refreshDiv, 5000);
});
于 2013-07-27T08:08:36.927 回答