使用 jQuery 将页面从表单加载到模态窗口

发布于 2024-08-23 19:38:10 字数 797 浏览 15 评论 0原文

我正在开发一个包含购买流程的网站。我有一个由 PHP 生成的表单,如下所示:

<form name="order_form" action="'.$thePayreadApi->get_server_url().'" method="post" id="payer-form">
'.$thePayreadApi->generate_form().'
<input type="submit" value="Klicka för betalning" />
</form>';

提交表单后,它将转到执行购买的新页面(位于另一台服务器上)。

基本上我想要的是通过 AJAX 提交表单,然后在模态窗口中加载新页面。我在整个网站中使用 jQuery,所以我想要一个基于该库的解决方案。

我发现这些网站可能是一个提示:

http://pixeline.be/blog/2008/javascript-loading-external-urls-in-jqmodal-jquery-plugin/ http://dev.iceburg.net/jquery/jqModal/

非常感谢任何帮助!

I´m working on a website with a purchase process. I have a form generated by some PHP that looks like this:

<form name="order_form" action="'.$thePayreadApi->get_server_url().'" method="post" id="payer-form">
'.$thePayreadApi->generate_form().'
<input type="submit" value="Klicka för betalning" />
</form>';

When the form is submitted it will go to a new page (located on another server) where the purchase is performed.

Basically what I want is the form to be submitted through AJAX and then load the new page in a Modal Window. I use jQuery throughout the website so I´d like a solution based on that lib.

I´ve found these sites that might be a hint:

http://pixeline.be/blog/2008/javascript-loading-external-urls-in-jqmodal-jquery-plugin/
http://dev.iceburg.net/jquery/jqModal/

Any help is really appreciated!

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

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

发布评论

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

评论(1

忆梦 2024-08-30 19:38:10

我还没有完全尝试过,但这个理论是我想要的:

$("form[name='order_form']").submit(function() {

    //Validate in here
    var validate = false;
    if($("input[form='element1']").val()!="") {
        validate = true;
    }
    if(validate) {
        this.submit();
    } else {
        return false;
    }
});

<form action="shopping.php" target="targetIframe" method="post">
    <input type="submit" value="Click Me" />
</form>

<iframe name="targetIframe" src=""></iframe>

I haven't tried this exactly, but the theory is what I would go for:

$("form[name='order_form']").submit(function() {

    //Validate in here
    var validate = false;
    if($("input[form='element1']").val()!="") {
        validate = true;
    }
    if(validate) {
        this.submit();
    } else {
        return false;
    }
});

<form action="shopping.php" target="targetIframe" method="post">
    <input type="submit" value="Click Me" />
</form>

<iframe name="targetIframe" src=""></iframe>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文