在php中提交表单后,成功消息模式未加载



我有一个表单,它是模态的,当用户单击按钮时,模态打开,他填写详细信息,提交后,详细信息会转到我的邮件中,直到这里一切都很好。在提交按钮之后,页面再次加载,所以我创建了一个感谢消息的模式,如下所示:

<?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 :" . "nn" . $first_name. "nn" .$last_name. "nn" .$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">&times;</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>

但在用户提交详细信息后,弹出的感谢消息没有加载,有人能告诉我我做了什么吗。提前感谢

$(window).load(function ());在最新版本的jQuery中不起作用。

因此,只需替换以下代码即可。

$(window).on("load", function () {
$('#thankyouModal').modal('show');
});

最新更新