2014-02-07 143 views
0

从我的主页我打开一个fancybox,我通过JQUERY AJAX请求提交信息。无法在IE和Chrome中使用jQuery Ajax重新加载DIV

然后,此提交应使用JQUERY .LOAD命令在主页上填充DIV。

奇怪的是,我只能得到这个在Firefox中工作。

我喜欢它也适用于Chrome和IE浏览器,但无法看到我的AJAX调用出现问题。有人能帮助吗?

$.ajax({ 
     type: "POST", 
      url: "../ajax/add-ingredient-to-recipe.php?"+dataString, 
      dataType: "html", 
      data: dataString, 

      }).done(function(){ 

      top.frames.$.fancybox.close(true); 
      top.frames.$('.calorie-table').load('./views/nutritional-data.tmp.php', function(){ 

       top.frames.$('.calorie-table').hide(); 
       top.frames.$('.calorie-table').fadeIn(800).css({backgroundColor: "#dddddd" }); 

      }); 
     }); 
+0

你得到任何控制台Chrome中出现错误?查看开发人员标签 编辑:嗯看起来像top.frames无法在Chrome中工作。看看这个问题:http://stackoverflow.com/questions/18762352/top-frames-wont-work-in-chrome – Ruben

+0

我怀疑'top.frames'是什么导致你的问题:http://跨浏览器.com/talk/inter-frame_comm.html –

+0

我认为top.frames可能会导致一些问题,但是,如果我删除它fancybox甚至不会关闭。我会检查你提供的链接Jeffrey – useyourillusiontoo

回答

0

所以我想通了,希望它能帮助其他人有同样的问题。

我工作的MAC所以在IE无法测试,但它工作在Safari,Chrome浏览器,火狐

我不得不从父页面重新加载的div $(“卡路里表”),而不是从AJAX请求。

这是在脚本中做到这一点打开的fancybox,现在读父页上:

$(".add-food-button").fancybox({ 
    width : 750, 
    height : 430, 
    fitToView : false, 
    autoSize : false, 
    transitionIn : 'elastic', 
    transitionOut : 'elastic', 
    type    : 'iframe', 
    afterClose : function() { 
     $('.calorie-table').load('./views/nutritional-data.tmp.php'); 
     $('.calorie-table').hide(); 
     $('.calorie-table').fadeIn(800); 
    } 

    }); 

我的AJAX调用现在看起来是这样的:

  $.ajax({ 
     type: "POST", 
      url: "../ajax/add-ingredient-to-recipe.php?"+dataString, 
      dataType: "html", 
      data: dataString, 

      }).done(function(){ 

      window.top.$.fancybox.close(true); 

     });