我读过很多关于 IE 和 jquery 的帖子(问题),但从来没有想过我会问如何让它在 Firefox 中工作,因为它在 IE9(没有缓存的 header )和 Chrome 中工作得很好。
$(document).ready(function(){
setInterval(function(){
$.post("dashBoardsql.php", {track : 2}, function(pendingReq){
$("#myTable").html(pendingReq);
}),
"html" });
}, 27000);
是我的jquery代码吗,就像我说的,它在IE9和Chrome中工作正常,但我必须在FF12中刷新页面才能看到pendingReq传回的更新。我使用 Firebug 来观察带有 POST 数据的控制台,它会一直保持到我 F5 页面为止。此外,没有报告任何错误,并且我的无缓存 header 必须重新验证已就位:
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
有什么建议吗?另外值得注意的是,测试是在我的本地计算机上使用 WAMP 完成的,因此没有跨域问题
解决了!这个问题"is"一个语法错误,但不是按照建议的方式,@KevinB fiddle 上的示例向我展示了,从上面的原始代码来看,它现在看起来像:
$(document).ready(function(){
setInterval(function(){
$.post("dashBoardsql.php?_=" + $.now(), {track : 2}, function(pendingReq){
$("#myTable").html(pendingReq);
}),
"html"
}, 27000);
});
加上所有标题信息,但我看到所有新时间戳都出现并且发生更新。谢谢大家!
最佳答案
尝试向 URL 添加反缓存字符串。
$.post("dashBoardsql.php?_=" + $.now(), ...)
关于jquery - Firefox 12 未使用 jquery post 进行更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10486088/