2014-04-03 5 views
1

성공적인 양식 제출 후 페이지를 다시로드 할 때 "감사합니다"모달을 표시하려고합니다. 모든 일이 발생하지 모달을 보여주는를 제외하고 잘 작동하는지양식 제출 후 부트 스트랩 모달 표시

<?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 
    } 
?> 

:

다음은 <head>의 하단에 내 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

는 자바 스크립트 주위에 $(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

도와 드리겠습니다! 감사 –

관련 문제