我有一个表格,位于远程模式窗口中。这是index.html中的模式:
<a data-toggle="modal" href="contact.html" data-target="#myModal">Contact Me</a>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
这里是contact.html中的精确形式:
<script>
$('#pop').popover({content: 'Message send.'},'click');
</script>
<form id="contactform" method="post" action="data/send_mail.php">
<!--
here is whole form content
-->
<button type="submit" value="Submit" class="btn btn-custom" data-toggle="popover" data-placement="right" id="pop">Send</button>
</form>
现在我的问题是:我没有单击提交按钮,而是在真正发送表单之后,需要显示引导弹出窗口。我在浏览器中进行验证(没有php正则表达式或jQuery验证,仅在浏览器中进行)。我的方法是遵循的(在从send_mail.php中收集数据并在其中创建消息之后):
@mail($email_to, $email_subject, $email_message, $headers);
/* Here should be something that will make my popover show, like: echo ('$('#pop').popover('show')');*/
sleep(2);
echo "<meta http-equiv='refresh' content=\"0; url=../index.html\">";
但是第二个命令(在注释中不起作用)。我是php方面的新手,因此,我尝试使解决方案尽可能简单。我希望我已经正确解释了我的问题。谢谢...
无需将放在action
表单上,您可以将其保留为空白,然后使用jquery进行Submit调用。
脚本
该脚本将与您的沟通能力data/send_mail.php
和从所获得的价值html input
它有一个id of name
我们可以PAS作为参数传递给send_mail.php
。
<script type="text/javascript">
$('#myButton').on('submit', function(){
var data_value = $('#name').val();
var data_value2 = $('#name2').val();
var data_value3 = $('#name3').val();
var url = 'data/send_mail.php';
$.ajax({
type: "GET",
url: url,
data:{'data_to_pass':data_value,
'second_data': data_value2,
'third_data': data_value3},
success:function(){
$('#pop').popover('show');
}
});
});
</script>
完整的URL将是 data/send_mail.php?data_to_pass=data_value
的HTML
<form>
<input id="name" type="text" placeholder="input something here" required />
<button id="button" type="button" value="Submit" class="btn btn-custom" data-toggle="popover" data-placement="right" id="pop">Send</button>
</form>
希望这可以帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句