我正在使用jQuery ajax将数据加载到jQuery选项卡中。它在Chrome和FireFox中运行良好。在IE8中,有时不会加载数据。如果我清除缓存或重新加载页面,它显然工作正常。
据我所知,在关闭IE并在一段时间后再次启动它时失败。它在几小时内就失败了,但如果延迟只有几分钟就会成功。至少这就是我认为的失败模式,我没有严格确定一个神奇的时间。
ETA:如果我清除缓存或刷新页面,它会起作用。
我在post数据中放了一个多余的时间参数,并在ajax调用中设置cache:false。
数据未缓存,因为如果我更改了预期的数据,它将正确地填充它。
另一个更新:
缺少数据。这是一个Facebook应用程序。结果证明是至关重要的。 我用Wireshark嗅到了工作和非工作会话。事实证明,不同之处在于工作会话提交Facebook Cookie,而不工作会话则不提供。
所以现在的问题是如何强制ajax调用包含cookie。我发现的关于ajax调用的描述是它包含cookie。我看到的行为是一个错误吗?
ETA:
javascript:
$.ajaxSetup
(
{
// Disable caching of AJAX responses
cache: false
}
);
$(document).ready
(
function()
{
$('#shopTabs').tabs();
thing.create();
thing.editPicture();
$('#shopTabs').bind
(
'tabsselect',
function(event, ui)
{
thing.setReload(ui.index);
thing.setActive(ui.index);
}
);
}
);
// Must be global for Java to call
function reload()
{
thing.create();
thing.editPicture();
}
var thing =
{
reload : 0,
active : 0,
noOp : function()
{
},
create : function()
{
date = new Date();
$('#shopTabs1').load('create.php', {time : date.getTime()}, thing.linkform);
},
editPicture : function()
{
date = new Date();
$('#shopTabs2').load('editPicture.php', {time : date.getTime()}, thing.noOp);
},
linkform : function()
{
$('#upload').ajaxForm({target : '#shopTabs1'});
},
setReload : function
(
index
)
{
this.reload = this.reloadList[index];
},
setActive : function
(
index
)
{
this.active = this.activeList[index];
},
load : function
(
php,
args,
loadFn
)
{
var settings =
{
type : "POST",
cache : false,
url : php,
data : args,
context : this,
success : function (data)
{
$(this.active).html(data);
loadFn();
}
}
$.ajax(settings);
}
};
thing.activeList = ['#ui-tabs-1', '#shopTabs1', '#shopTabs2'];
thing.reloadList = [thing.noOp, thing.create, thing.editPicture];
答案 0 :(得分:0)
在你的thing.create函数中,添加一个更改的查询参数,当前日期是好的,或使用随机数。
$('#shopTabs1').load('create.php?r='+escape(new Date().toString()), {time : date.getTime()}, thing.linkform);
或
$('#shopTabs1').load('create.php?r='+new Date().valueOf(), {time : date.getTime()}, thing.linkform);
与您的editPicture相同。
这将阻止IE缓存,正如Omu的回答所提到的那样
答案 1 :(得分:0)
事实证明,问题在于IE正式期望P3P标头从第三方网站加载iframe。 Facebook使用来自应用提供商的iframe实现应用。
如果没有P3P标头,IE不会一直失败。