I've found this colorbox tutorial
并尝试通过 POST 操作使其以相同的方式工作, 但它不起作用,它只是不断加载。
按钮是不好用的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/