2014-04-03 40 views
1

我想在成功提交表單後重新加載頁面時顯示「謝謝」模式。在提交表單後顯示引導模式

這是我在<head>底部PHP:

<?php 
    if (isset($_POST["email"]) && !empty($_POST["email"])) 
    { 
     $response_text = "Thanks, we'll be in touch soon!"; 
     include('connect.php'); 
     mysqli_query($con, "INSERT INTO sh_betalist (email, ip_address, signup_loc) VALUES ('" . $_POST['email'] . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . "homepage')"); 
     ?> 
     <script type="text/javascript"> $('#thankyouModal').modal('show'); </script> 
     <?php 
    } 
?> 

這一切工作,除了顯示模式,這不會發生的罰款。我沒有在JS控制檯中出現任何錯誤。

這裏是我的語氣在<body>的底部:

<div class="modal fade" id="thankyouModal" tabindex="-1" role="dialog" aria-labelledby="thankyouLabel" aria-hidden="true"> 
    <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>You'll be the first to know when Shopaholic launches.</p>      
       <p>In the meantime, any <a href="http://shopaholic.uservoice.com/" target="_blank">feedback</a> would be much appreciated.</p> 
      </div>  
     </div> 
    </div> 
</div> 

回答

3

儘量纏繞在JavaScript中的$(document).ready

<?php 
    if (isset($_POST["email"]) && !empty($_POST["email"])) 
    { 
     $response_text = "Thanks, we'll be in touch soon!"; 
     include('connect.php'); 
     mysqli_query($con, "INSERT INTO sh_betalist 
     (email, ip_address, signup_loc) VALUES ('" . $_POST['email'] . "', '" . 
     $_SERVER['REMOTE_ADDR'] . "', '" . "homepage')"); 
?> 
     <script type="text/javascript"> 
     $(document).ready(function(){ 
      $('#thankyouModal').modal('show'); 
     }); 
     </script> 
    <?php 
} 
?> 
+3

原來是這麼簡單!將在9分鐘內接受。 – Sebastian

+0

很高興幫助!謝謝 –