admin管理员组文章数量:1401643
Im using Spring MVC In My editStatus.jsp I have the following code to refresh a DIV every 5 seocnds
function refreshDiv(){
$.ajax({
url: 'editStatus.jsp'
}).done(function(result) {
$('#refreshDIV').text(result);
});
}
And My DIV code is
<div class="span5">
<div class="row-fluid form-inline">
<h4 class="inline">
<spring:message code='alert.status' />
</h4>
</div>
<div class="row-fluid">
<div class="span5 row-fluid">
<div class="span9">
<div class="row-fluid">
<div class="span12">
<label>
<spring:message code='alert.sent' />:
</label>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<label>
<spring:message code='alert.in.progress' />:
</label>
</div>
</div>
</div>
</div>
<!-- this has to be calculated, loop through 3 times seems excessive -->
<c:forEach var="channel" items="${StatusForm.channels}">
<c:set var="currentChannel" value=""></c:set>
<c:set var="channelIcon" value=""></c:set>
<c:if test="${channel == 'Email'}" >
<c:set var="currentChannel" value="EMAIL"></c:set>
<spring:url value="/static/img/icon_email_channel.png" var="channelIcon" />
</c:if>
<c:if test="${channel == 'SmsChannel'}" >
<c:set var="currentChannel" value="SMS"></c:set>
<spring:url value="/static/img/icon_sms_channel.png" var="channelIcon" />
</c:if>
<c:if test="${channel == 'VoiceChannel'}" >
<c:set var="currentChannel" value="VOICE"></c:set>
<spring:url value="/static/img/icon_voice_channel.png" var="channelIcon" />
</c:if>
<div id="refreshDiv" class="span3" >
<c:set var="map" value="${StatusForm.channelStateForRecipients[currentChannel]}"></c:set>
<div>
<label style="color:black" ><img src="${channelIcon}">
${fn:length(StatusForm.totalSentRecipient)}
</label>
</div>
<div>
<label style="color:black"><img src="${channelIcon}">
${fn:length(StatusForm.totalNotSentRecipient)}
</label>
</div>
<div>
<label style="color:black"><img src="${channelIcon}">
${fn:length(StatusForm.totalInProgressRecipient)}
</label>
</div>
</div>
</c:forEach>
</div>
</div>
From above code I want to auto-refresh the following however the same is not working
<div id="refreshDiv" class="span3" >
<c:set var="map" value="${StatusForm.channelStateForRecipients[currentChannel]}"></c:set>
<div>
<label style="color:black" ><img src="${channelIcon}">
${fn:length(StatusForm.totalSentRecipient)}
</label>
</div>
<div>
<label style="color:black"><img src="${channelIcon}">
${fn:length(StatusForm.totalNotSentRecipient)}
</label>
</div>
<div>
<label style="color:black"><img src="${channelIcon}">
${fn:length(StatusForm.totalInProgressRecipient)}
</label>
</div>
</div>
Should the URL refreshing code go through the controller ?
I tried with
$(document).ready(function () {
alert('Hi OutBound');
var seconds = 5000; // time in milliseconds
var reload = function() {
alert('Inside Reload');
$.ajax({
url: 'editStatus.jsp',
cache: false,
success: function(data) {
alert('Inside 2');
$('#refreshDIV').html(data);
setTimeout(function() {
alert('Inside SettimeOut');
reload();
}, seconds);
}
});
};
reload();
});
However Alerts alert('Inside 2'); and alert('Inside SettimeOut'); never get called. Please suggest
Im using Spring MVC In My editStatus.jsp I have the following code to refresh a DIV every 5 seocnds
function refreshDiv(){
$.ajax({
url: 'editStatus.jsp'
}).done(function(result) {
$('#refreshDIV').text(result);
});
}
And My DIV code is
<div class="span5">
<div class="row-fluid form-inline">
<h4 class="inline">
<spring:message code='alert.status' />
</h4>
</div>
<div class="row-fluid">
<div class="span5 row-fluid">
<div class="span9">
<div class="row-fluid">
<div class="span12">
<label>
<spring:message code='alert.sent' />:
</label>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<label>
<spring:message code='alert.in.progress' />:
</label>
</div>
</div>
</div>
</div>
<!-- this has to be calculated, loop through 3 times seems excessive -->
<c:forEach var="channel" items="${StatusForm.channels}">
<c:set var="currentChannel" value=""></c:set>
<c:set var="channelIcon" value=""></c:set>
<c:if test="${channel == 'Email'}" >
<c:set var="currentChannel" value="EMAIL"></c:set>
<spring:url value="/static/img/icon_email_channel.png" var="channelIcon" />
</c:if>
<c:if test="${channel == 'SmsChannel'}" >
<c:set var="currentChannel" value="SMS"></c:set>
<spring:url value="/static/img/icon_sms_channel.png" var="channelIcon" />
</c:if>
<c:if test="${channel == 'VoiceChannel'}" >
<c:set var="currentChannel" value="VOICE"></c:set>
<spring:url value="/static/img/icon_voice_channel.png" var="channelIcon" />
</c:if>
<div id="refreshDiv" class="span3" >
<c:set var="map" value="${StatusForm.channelStateForRecipients[currentChannel]}"></c:set>
<div>
<label style="color:black" ><img src="${channelIcon}">
${fn:length(StatusForm.totalSentRecipient)}
</label>
</div>
<div>
<label style="color:black"><img src="${channelIcon}">
${fn:length(StatusForm.totalNotSentRecipient)}
</label>
</div>
<div>
<label style="color:black"><img src="${channelIcon}">
${fn:length(StatusForm.totalInProgressRecipient)}
</label>
</div>
</div>
</c:forEach>
</div>
</div>
From above code I want to auto-refresh the following however the same is not working
<div id="refreshDiv" class="span3" >
<c:set var="map" value="${StatusForm.channelStateForRecipients[currentChannel]}"></c:set>
<div>
<label style="color:black" ><img src="${channelIcon}">
${fn:length(StatusForm.totalSentRecipient)}
</label>
</div>
<div>
<label style="color:black"><img src="${channelIcon}">
${fn:length(StatusForm.totalNotSentRecipient)}
</label>
</div>
<div>
<label style="color:black"><img src="${channelIcon}">
${fn:length(StatusForm.totalInProgressRecipient)}
</label>
</div>
</div>
Should the URL refreshing code go through the controller ?
I tried with
$(document).ready(function () {
alert('Hi OutBound');
var seconds = 5000; // time in milliseconds
var reload = function() {
alert('Inside Reload');
$.ajax({
url: 'editStatus.jsp',
cache: false,
success: function(data) {
alert('Inside 2');
$('#refreshDIV').html(data);
setTimeout(function() {
alert('Inside SettimeOut');
reload();
}, seconds);
}
});
};
reload();
});
However Alerts alert('Inside 2'); and alert('Inside SettimeOut'); never get called. Please suggest
Share Improve this question edited Aug 29, 2013 at 10:40 ronan asked Aug 29, 2013 at 6:12 ronanronan 4,67213 gold badges53 silver badges68 bronze badges 1-
who is invoking the
refreshDiv
method – Arun P Johny Commented Aug 29, 2013 at 6:15
1 Answer
Reset to default 4I think your refresh function is inplete, for instance there's nothing that makes it loop. Try something like this:
$(document).ready(function () {
var seconds = 5000; // time in milliseconds
var reload = function() {
$.ajax({
url: 'editStatus.jsp',
cache: false,
success: function(data) {
$('#refreshDIV').html(data);
setTimeout(function() {
reload();
}, seconds);
}
});
};
reload();
});
本文标签: javascriptAuto Refresh DIV contents every 5 seconds code not workingStack Overflow
版权声明:本文标题:javascript - Auto Refresh DIV contents every 5 seconds code not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744265070a2597909.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论