将 html 表单与 jQuery 插件集成

发布于 2024-12-07 03:47:32 字数 293 浏览 0 评论 0原文

我有一个 HTML 表单,它将数据提交到 cgi-bin 脚本,而 cgi-bin 脚本又提供一些输出。

我看过这个例子显示带有 jQ​​uery 的模式框。这对于显示 cgi-bin 的输出来说是完美的!问题是这个例子适用于 并且我无法用链接替换提交按钮。我该怎么办?

I have a HTML form which submits the data to a cgi-bin script which in turns provides some output.

I have seen this example that show a modal box with jQuery. This would be perfect for showing the output of the cgi-bin! The problem is that this example works with a
<a href> and I can't replace the submit button with a link. How should I do?

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

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

发布评论

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

评论(1

独守阴晴ぅ圆缺 2024-12-14 03:47:32
$('#your-form').submit(function(e){
    e.preventDefault(); // make sure form is NOT submitted by the browser as this would make us navigate away from the current page and therefor render our modal window useless
    $this = $(this); // cache $(this) for better performance
    $.post( // submit the form via POST ...
        $this.attr('action'), // ... to the action URL of our form
        $this.serialize(), // ... with all the form fields as data
        function(data) { // ... and with the server response ...
            $(data).appendTo('body').paulund_modal_box().click(); // ... open the modal.
            // note that the click() is only required for the rather quirky "plugin" that you linked to. I suggest using easybox or the like
        }
    );
});
$('#your-form').submit(function(e){
    e.preventDefault(); // make sure form is NOT submitted by the browser as this would make us navigate away from the current page and therefor render our modal window useless
    $this = $(this); // cache $(this) for better performance
    $.post( // submit the form via POST ...
        $this.attr('action'), // ... to the action URL of our form
        $this.serialize(), // ... with all the form fields as data
        function(data) { // ... and with the server response ...
            $(data).appendTo('body').paulund_modal_box().click(); // ... open the modal.
            // note that the click() is only required for the rather quirky "plugin" that you linked to. I suggest using easybox or the like
        }
    );
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文