javascript - 如何使 POST Action 与 jquery/ajax Colorbox 一起工作? (里面的 fiddle )

标签 javascript php jquery ajax colorbox

I've found this colorbox tutorial

并尝试通过 POST 操作使其以相同的方式工作, 但它不起作用,它只是不断加载。

here's a fiddle

按钮是不好用的POST Action , 文本链接是可以正常工作的原始示例。

我不能在 fiddle 上显示这个, 但基本上我是将表单发布到一个带有开关/大小写的简单 PHP 文件。

我怎样才能让它工作?

最佳答案

因为您不能使用表单作为触发器,所以插件不会以这种方式完成,唯一的方法是如果您在提交按钮上使用点击事件。 在您的表单中将 id 添加到提交按钮:

<form action="ajax.html" method="POST" target="_blank" class="">
    <input id="111" name="a" type="hidden" value="something-else"  />
    <input type="submit" id="cboxFormButton" class="button" value="Test">
</form>

然后在你的脚本中添加:

$("#cboxFormButton").click(function(e){

    e.preventDefault();

    // Call the colorbox link from here...
    $.colorbox({href:"/echo/html/"});

    // if you want to the form action url do this
    // $.colorbox({href: $(this).closest('form').attr('action') });

});

关于javascript - 如何使 POST Action 与 jquery/ajax Colorbox 一起工作? (里面的 fiddle ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21937323/

相关文章:

php file_get_contents 向 Bugzilla 安装发送错误的内容类型

javascript 缺少 ) 参数

javascript - 如何在 handsontable 中获取表头名称

javascript - Websocket 向服务器发送垃圾

javascript - 在 if()else() 之前等待函数完成

java - 如何将 HTML 表单提交重定向到 iframe?

php - 我们如何使用 Firebase 云消息传递 (fcm) 在 android 中发送图像和图标以进行推送通知

php - 如何使用 bind_param 将图像插入 MySQL 表

javascript - 单击没有 ID 和名称

javascript - 当选中特定复选框时如何显示和隐藏 div?