簡體   English   中英

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

[英]after submitting form in php, success message modal not loading

我有一個模態的表單,當用戶單擊按鈕時,模態打開並填寫詳細信息,然后將詳細信息 go 提交到我的郵件,直到這里一切都很好。 提交按鈕后,頁面再次加載,所以我創建了一個模式來表示感謝消息,如下所示:

 <?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">&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');
    });

我認為 jQuery 沒有正確加載所以請嘗試使用下面的代碼庫。

$(document).ready(function() {
    $('#thankyouModal').modal('show');
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM