如何 return 模态提交表单的结果
How to return results of submitted form in a modal
我在 contactpage1.php 上有一个联系表(部门、姓名、电子邮件、消息)。提交时,表单 'action' 是 contactpage2.php,它验证数据和 return 错误消息或通过电子邮件发送消息。
与其必须转到 contactpage2.php,我更愿意将所有内容都放在一个页面上,并以模式打开 contactpage2.php。
我该怎么做?
到目前为止,我已经看到很多单击按钮打开带有联系表单的模式的示例,但这不是我想要的。我可以按照上面的方法做吗?
我在网站的其他地方使用 Bootstrap 模式。
答案取自 by Shehary
Here are the steps according to your question
- you have form on
contactpage1.php
.
- Submit it with Ajax.
- show modal in Ajax success function with
$('#selector').modal('show');
You can also bind the element in modal to show the message in modal,
so what you need is the Ajax Method and all other steps can be taken
care inside Ajax call.
我在 contactpage1.php 上有一个联系表(部门、姓名、电子邮件、消息)。提交时,表单 'action' 是 contactpage2.php,它验证数据和 return 错误消息或通过电子邮件发送消息。
与其必须转到 contactpage2.php,我更愿意将所有内容都放在一个页面上,并以模式打开 contactpage2.php。
我该怎么做?
到目前为止,我已经看到很多单击按钮打开带有联系表单的模式的示例,但这不是我想要的。我可以按照上面的方法做吗?
我在网站的其他地方使用 Bootstrap 模式。
答案取自
Here are the steps according to your question
- you have form on
contactpage1.php
.- Submit it with Ajax.
- show modal in Ajax success function with
$('#selector').modal('show');
You can also bind the element in modal to show the message in modal, so what you need is the Ajax Method and all other steps can be taken care inside Ajax call.