我有一个表单形式的表单,当用户单击按钮时,该表单将打开,他将填写详细信息,并在提交详细信息后将其发送到我的邮件中,直到一切正常为止。提交按钮之后,页面再次加载,因此我为感谢消息创建了一个模态,如下所示:
<?php
if(isset($_POST['submit'])){
$to = "contact@solutions.com"; // this is your Email address
$from = $_POST['name1']; // this is the sender's Email address
$first_name = $_POST['name2'];
$last_name = $_POST['email2'];
$last_name1 = $_POST['number1'];
$subject = "Referal";
$subject2 = "Bolster Referal.";
$message = $from . " has refered the following student :" . "\n\n" . $first_name. "\n\n" .$last_name. "\n\n" .$last_name1;
$message2 = "Your friend " . $from . " has refered you to us" ;
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($last_name,$subject2,$message2,$headers2); // sends a copy of the message to the sender
//echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
echo "<script>
$(window).load(function(){
$('#thankyouModal').modal('show');
});
</script>";
}
?>
<div class="modal fade" id="thankyouModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Thank you for pre-registering!</h4>
</div>
<div class="modal-body">
<p>Thanks for getting in touch!</p>
</div>
</div>
</div>
</div>
但是在用户提交详细信息之后,感谢消息弹出窗口没有加载,有人可以告诉我我做错了什么吗?预先感谢
答案 0 :(得分:0)
$(window).load(function ());
在最新版本的jQuery中不起作用。
所以只需替换以下代码。
$(window).on("load", function () {
$('#thankyouModal').modal('show');
});