Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从fancybox iframe在站点上查找元素_Javascript_Jquery_Asp.net Mvc 2_Fancybox - Fatal编程技术网

Javascript 从fancybox iframe在站点上查找元素

Javascript 从fancybox iframe在站点上查找元素,javascript,jquery,asp.net-mvc-2,fancybox,Javascript,Jquery,Asp.net Mvc 2,Fancybox,我正在尝试从fancybox更新网站上的一个元素。在fancybox中,我执行一个$.post(),然后返回要填充到页面上div中的html数据。我用html打开了一个iframe窗口,下面的脚本就在iframe中。它无法从fancybox中找到它,因此任何人都有了关于如何到达fancyboxiframe之外的元素的想法或解决方案 $('.add-to-cart').click(function () { var $this = $(this).closest('form');

我正在尝试从fancybox更新网站上的一个元素。在fancybox中,我执行一个
$.post()
,然后返回要填充到页面上div中的
html
数据。我用
html
打开了一个
iframe
窗口,下面的脚本就在
iframe
中。它无法从fancybox中找到它,因此任何人都有了关于如何到达fancybox
iframe
之外的元素的想法或解决方案

$('.add-to-cart').click(function () {
    var $this = $(this).closest('form');

    $.post($this.attr('action'), { quantity: $this.find('#quantity_id').val() }, function (data) {
        parent.$.fancybox.close();
        $('#container').html(data);
    }, 'html');

    return false;
});
试试这个:

$('#container', $(parent.document)).html(data);