使用 fancybox 的 AJAX post 不起作用

发布于 2025-01-08 18:49:46 字数 730 浏览 5 评论 0原文

我的脚本:

$("#sl_selections").fancybox({
    'width'             : 370,
    'height'            : 480,
    'autoDimensions'    : false,//(width != '' || height != '' ? false : true),
    'autoScale'         : false,
    'showCloseButton'   : false,
    'titleShow'         : false,
    'padding'           : 0,
    'href'              : $('#itemInteractivity .copyMove a').attr('href'),
    'ajax'              : { data:  acao,type: 'post' }
});  

在 PHP 中返回一个空帖子。如果我这样做会很有趣:

$.ajax({
    type:           'post',
    cache:          false,
    url:            $('#itemInteractivity .copyMove a').attr('href'),
    data:           {data:  acao}
});

工作正常,有什么想法吗?

my script:

$("#sl_selections").fancybox({
    'width'             : 370,
    'height'            : 480,
    'autoDimensions'    : false,//(width != '' || height != '' ? false : true),
    'autoScale'         : false,
    'showCloseButton'   : false,
    'titleShow'         : false,
    'padding'           : 0,
    'href'              : $('#itemInteractivity .copyMove a').attr('href'),
    'ajax'              : { data:  acao,type: 'post' }
});  

in PHP return an empty post. Interesting if I make this:

$.ajax({
    type:           'post',
    cache:          false,
    url:            $('#itemInteractivity .copyMove a').attr('href'),
    data:           {data:  acao}
});

works fine, any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笔落惊风雨 2025-01-15 18:49:46

老问题,但没有可接受的答案。

使用 Fancybox 2,我可以通过 AJAX 获取帖子以使用以下配置:

$.fancybox.open({
    type: "ajax",
    ajax: {
        dataType: "html",
        type: "POST",
        data: {
            "foo" : "bar",
            "foo2" : "test"
        }
    },
    href: "url-to-post-to.php"
})

Old question, but no acceptable answer.

Using Fancybox 2, I am able to get a post via AJAX to work with the following configuration:

$.fancybox.open({
    type: "ajax",
    ajax: {
        dataType: "html",
        type: "POST",
        data: {
            "foo" : "bar",
            "foo2" : "test"
        }
    },
    href: "url-to-post-to.php"
})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文