2011-03-12 84 views
0

我正在使用jQuery ajax将数据加载到jQuery选项卡中。它在Chrome和FireFox中运行良好。在IE8中,数据有时不会加载。如果我清除缓存或重新加载页面,它显然工作正常。使用IE8的jQuery ajax间歇性故障

据我可以告诉它关闭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

服务器的响应头是什么? – 2011-03-12 21:23:58

+0

除了Matt的问题,你可以发布你的任何代码吗?这将有助于我们更好地回答这个问题。 – JasCav 2011-03-12 21:26:26

回答

0

原来的问题是,IE郑重希望P3P头从第三第三方网站加载的iframe提及。 Facebook使用应用程序提供商提供的iframe来实施应用程序。

如果没有P3P标头,IE不会始终失败。

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的回答