简体   繁体   English

fancybox ajax发布到iframe

[英]fancybox ajax post to iframe

is it possible using fancybox to post a var to the iframe when opens? 是否可以使用fancybox在打开时将var发布到iframe?

I currently have: 我目前有:

function fancyBoxLoad(element) {
    var elementToEdit = $("#" + $(element).attr("class"));
    var content = encodeURIComponent($(elementToEdit).outerHTML());
    $.fancybox(
        { 'href': 'loadEditor.php' },
        {
            frameWidth: 750,
            frameHeight: 430,
            overlayShow: true,
            ajax: {
                type: "POST",
                data: 'content=' + content
            },
            type: 'iframe'
        }
    );
}

It does seem that if I take away type: 'iframe' it will post data but it doesn't appear to be in the iframe and if I take away ajax: { type: "POST", data: 'content=' + content } instead it will open in an iframe but not post the data (the example above does the same) 似乎如果我带走type: 'iframe'它将发布数据,但它似乎不在iframe中,如果我带走了ajax: { type: "POST", data: 'content=' + content }代替它会在iframe打开但不上传的数据(上面的例子不相同)

So my question being can it be done? 所以我的问题是可以做到吗?

If you're simply trying to put content in a iframe, why don't you use fancybox to create the iframe, and once you know it's been created, then access it via the reference that fancybox returns to you and set your content that way. 如果您只是想将内容放在iframe中,为什么不使用fancybox来创建iframe,一旦您知道它已经创建,然后通过fancybox返回给您的引用访问它并以这种方式设置您的内容。 I'm not sure you want to send the content to the server and back. 我不确定您是否要将内容发送到服务器并返回。 Just wait for the iframe to load, then on ready, query an element within it and set the content. 只需等待iframe加载,然后准备就绪,查询其中的元素并设置内容。

Looking at the source for Fancybox v1.3.1 they are in fact mutually exclusive. 查看Fancybox v1.3.1的源代码,它们实际上是互斥的。 If you don't feel comfortable diving into the source code and editing the plugin, you might try using GET variables in your HREF as a work around. 如果您不熟悉源代码并编辑插件,可以尝试在HREF中使用GET变量作为解决方法。 It should effectively work like a post as it is an AJAX call, just make sure the backend can receive the GET variables. 它应该像帖子一样有效地工作,因为它是一个AJAX调用,只需确保后端可以接收GET变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM