将数据发布到colorbox iframe?

SRe*_*eca 4 iframe jquery post colorbox

这是我正在使用的代码.从我见过的其他例子来看,这应该有效,但事实并非如此.并且已经确定我使用的是最新的彩盒.

function updateFolderCate(ID,Type){
    $.colorbox({
        iframe:true,
        scrolling: false,
        innerWidth:'100',
        innerHeight:'100',
        href:"page.php",
        data:{LinkID:ID,itemType:Type},
        onClosed:function(){
            //Do something on close.
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

Eri*_*sen 11

您将iframe设置为true.这样做会打开一个颜色框,创建一个iframe,并将iframe的src属性设置为href指定的位置.所以逻辑上这不能做POST请求.这可能会实现你想要的,但我不确定.

function updateFolderCate(ID,Type){
    $.colorbox({
        open: true,
        scrolling: false,
        innerWidth:'100',
        innerHeight:'100',
        href:"page.php",
        data:{LinkID:ID,itemType:Type},
        onClosed:function(){
            //Do something on close.
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

这不会像iframe方法那样,您可能需要重新设计端点.如果您的端点不必仅接收POST请求,那么请使用earlonrails的回答.

编辑:我在潜水源代码后来到这里:来源

相关的行是第800行和第856行.iframe和href似乎不兼容,所以我检查了Firebug中加载的元素,发现它是一个iframe,src属性设置为href变量.