setInterval()正在启动,但ajax更新div内容不起作用



onDocumentReady(), $(function () {...})中,我有一行:window.setInterval("readPluginCache();", 3000);

readPluginCache()方法调用ajax调用来检索并格式化命名的$('#pluginCacheData')元素的替换html。

我可以在Chrome(F12(中看到,ajax启动、完成和成功事件每三秒记录一次(正如预期的那样(。

然而,新的html并没有取代旧的html值。。。我在页面上有一个按钮(作为备份(,它调用readPluginCache()方法;它有效!

如何使setInterval()方法论发挥作用?

function readPluginCache() {
if (!isAuthorized) {
addMessageError("Error: Unauthorized readCache attempt.");
return false;
}
$('#pluginCacheData').hide();
$.ajax({
type: "POST",
url: infoPageName + "/BriskPluginCacheInfoHtml",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json"
}).done(function (response) {
$('#pluginCacheData').empty();
$('#pluginCacheData').append(response.d);
}).fail(function (jqXHR, exception) {
if (jqXHR.responseText.toLowerCase().indexOf('html') !== -1) {
addMessageError("Internal Server Error: readPluginCache().     Please check the event log.");
}
else
addMessageError("Error: " + jqXHR.responseJSON.Message);
alert(exception);
}).always(function () {
$('#pluginCacheData').show();
});
return true;
}

好吧,我开始工作了;但我不知道为什么这样。。。我已经通过封装另一个名为readAll((的函数抽象了原始ajax调用,所以:window.setInterval(readAll,3000(。readAll((按顺序调用三种不同的基于ajax的html/div修改方法。我做了这个b/c页面的其他部分也需要动态更新。。。对我来说,这是一个谜,为什么当一个ajax调用不起作用时,它会起作用。

最新更新