[英]reload page after ajax jquery
我正在尝试根据ajax响应重新加载页面,但页面闪烁但不刷新或重新加载页面,以下是我的代码。
function callAjaxForCount(getCountValue){
var maxValue = getCountValue;
var interval = 3000;
$.ajax({
type: "GET",
url: "/ServletToCheckCondition",
async: false,
data: {"totalLoggedMembers": maxValue},
success: function(data) {
for (var key in data) {
var retValue = data[key];
if(retValue == 'true')
{
location.reload();
}
else if(retValue == 'false')
{
}
}
},
error: function() {
alert("Failed. Try Again.","error");
},
complete: function () {
// Schedule the next
window.setInterval(callAjaxForCount(maxValue),interval);
}
});
}
这是在window.open弹出窗口中,此函数将在弹出窗口启动时调用,并且如果条件满足并返回true,则每3秒重复调用一次,然后必须重新加载页面,并且它将为页面动态设置新值,但是page是没有持续刷新其闪烁。
我使用location.reload(),我还尝试保持隐藏的按钮并提交页面,但没有运气。
尝试
function callAjaxForCount(getCountValue){
var maxValue = getCountValue;
var interval = 3000;
$.ajax({
type: "GET",
url: "/ServletToCheckCondition",
async: false,
data: {"totalLoggedMembers": maxValue},
success: function(data) {
for (var key in data) {
var retValue = data[key];
if(retValue == 'true')
{
window.location.reload();
}
else if(retValue == 'false')
{
}
}
},
error: function() {
alert("Failed. Try Again.","error");
},
complete: function () {
// Schedule the next
window.setInterval(callAjaxForCount(maxValue),interval);
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.