2016-09-16 79 views
0

下午好,我有一個web項目,準備好了,並且使用ajax和jquery驗證過的表單也有一個PHP函數,用於發送表單上的所有數據,並且我必須休息一個模式窗口boostratp,通過點擊提交激活,問題是,jquery阻止表單到php的通道,並不是只發送顯示模式。我想我激活從PHP jQuery的,但不完全怎麼辦呢表單未提交php和html

這是我的表格:

// What to do on submit - example of success message 
 

 
    // ------------------------------------------------- 
 

 
    submitHandler: function(form) { 
 

 
     $('#successForm').modal('show'); 
 

 
     return false; 
 

 
    } 
 

 
    }); 
 

 

 
// Reset the contact form when success message shown as bootstrap modal is dismissed 
 

 
// --------------------------------------------------------------------------------- 
 

 
$('#successForm').on('hidden.bs.modal', function() { 
 

 
    $('#contactForm').trigger("reset"); 
 

 
    $('#contactForm .form-group').find('.glyphicon').removeClass('glyphicon-ok'); 
 

 
});
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
 
    <script src="js/js-theme/jquery-1.11.3.js"></script> 
 
    
 
    <!-- Include all plugins (below), or include individual files as needed --> 
 
    <script src="js/js-bootstrap/affix.js"></script> 
 
    <script src="js/js-bootstrap/alert.js"></script> 
 
    <script src="js/js-bootstrap/button.js"></script> 
 
    <script src="js/js-bootstrap/carousel.js"></script> 
 
    <script src="js/js-bootstrap/collapse.js"></script> 
 
    <script src="js/js-bootstrap/dropdown.js"></script> 
 
    <script src="js/js-bootstrap/modal.js"></script> 
 

 

 
<form id="contactForm" name="contactForm" action="enviar.php" method="post" enctype="multipart/form-data" target="_top"> 
 
        <div class="col-lg-6"> 
 
        <div class="form-group has-feedback wow flipInX" data-wow-duration="600ms"> 
 
         <label for="nombre">Nombre*</label> 
 
         <input id="nombre" class="form-control input-lg" type="text" name="nombre" value="" placeholder="" aria-label="nombre" /> 
 
         <span id="nombre1" class="glyphicon form-control-feedback"></span> 
 
        </div> 
 
        <!-- end .form-group --> 
 
    
 
        <div class="form-group wow flipInX" data-wow-duration="900ms"> 
 
         <label for="celular">Celular</label> 
 
         <input id="celular" class="form-control input-lg" type="text" name="celular" value="" placeholder="" aria-label="celular" /> 
 
        </div> 
 
        <!-- end .form-group --> 
 
    
 
        <div class="form-group has-feedback wow flipInX" data-wow-duration="800ms"> 
 
         <label for="email">Email*</label> 
 
         <input id="email" class="form-control input-lg" type="email" name="email" value="" placeholder="" aria-label="email" /> 
 
         <span id="email1" class="glyphicon form-control-feedback"></span> 
 
        </div> 
 
        <!-- end .form-group --> 
 
        </div> 
 
    
 
        <div class="col-lg-6"> 
 
        <div class="form-group has-feedback wow flipInX" data-wow-duration="1000ms"> 
 
         <label for="mensaje">Mensaje*</label> 
 
         <textarea id="mensaje" class="form-control" name="mensaje" rows="10" ></textarea> 
 
         <span id="mensaje1" class="glyphicon form-control-feedback"></span> 
 
        </div> 
 
        <!-- end .form-group --> 
 
        </div> 
 
    
 
        <div class="clearfix"></div> 
 
    
 
        <div class="text-center"> 
 
        <div class="form-group wow zoomInDown" data-wow-duration="800ms"> 
 
         <button id="submitContact" type="submit" class="btn btn-default btn-lg">Enviar</button> 
 
         <button class="btn btn-danger btn-lg" type="reset">Borrar</button> 
 
        </div> 
 
        <!-- end .form-group --> 
 
        </div> 
 
        <!-- end .text-center --> 
 
       </form> 
 

 

 

 

 

 
    <!-- Modal success on submit --> 
 
    <div class="theme-submit-success-modal"> 
 
     <div class="modal fade" id="successForm" tabindex="-1" role="dialog" aria-labelledby="successFormModalLabel"> 
 
     <div class="modal-dialog" role="document"> 
 
      <div class="modal-content"> 
 
      <div class="modal-body"> 
 
       <div class="text-center"> 
 
       <span class="fa fa-comments-o"></span> 
 
       </div> 
 
       <h4 class="text-center" name="modal_contact" id="successFormModalLabel">Enviado Con Éxito</h4> 
 
       <p class="text-center">Gracias por contactarnos, en breve contestaremos a su mensaje. </p> 
 
      </div> 
 
      <div class="modal-footer"> 
 
       <div class="text-center"> 
 
       <button type="button" class="btn btn-default" data-dismiss="modal">OK</button> 
 
       </div> 
 
      </div> 
 
      </div> 
 
     </div> 
 
     </div> 
 
    </div>

+3

您可能想發佈一個較短的示例。刪除對問題不重要的內容,例如插件。他們讓你更難測試你的例子。 – David

+0

你檢查了你的控制檯是否有錯誤? JS或PHP應該拋出一個提示問題出在哪裏。 –

回答

0

你應該開始學習如何製作網站。這麼簡單的表單代碼?!

我認爲,您最好在表單發送完成後顯示模態,而不僅僅是提交。

是否有返回false這裏的一個原因:

submitHandler: function(form) { 
    $('#successForm').modal('show'); 
    return false; 
} 

這可能是防止其他必要的代碼執行。