0

i am trying to close modal window immediately after form is submitted. modal window consists of login form which updates data in php mysql. Everything is going fine except closing part:

    <div id="register"><a data-toggle="modal" href="#RModal" class="btn btn-primary btn-lg">SIGN UP</a></div>
        <!-- Modal -->

                    <h4 class="modal-title">REGISTRATION FORM</h4>
                </div>
            <div class="modal-body">

            <div id="contact_form">  
            <form id="register-form" name="contact" action=""> 
            <fieldset>

                <div class="field_container">&nbsp; &nbsp; &nbsp; Email:</label>
                <input type="text" name="cust_email" id="email"  maxlength="100" onblur="emvalidation()" style="width: 250px; height: 30px"; />

                <div class="field_container">Password:</label>
                <input type='password' name='cust_password' id='password'  maxlength="12" onblur="pwordvalidation()" style="width: 250px; height: 30px"; />


                </div>
            <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            <INPUT class="btn btn-primary" type="submit" name="submit" value="Register" >
            </fieldset>  
            </form>

jquery to submit and process data:

     $(document).ready(function(){
     $("#register-form").submit(function(){
     var str = $(this).serialize();
      $.ajax(
      {
      type: "POST",
      url: "register_process.php",
      data: str,
      success:function(result)
                {
                $(" #register .modal-body").load('login_succesful.php');
                }
       });
   return false;
   });
   });

It doesnt get closed when submitted. (processing of data is happening). Also when session is set in php, content of ".message" doesnt appear automatically, but after a refresh.

4

1 回答 1

0

您没有提供太多信息,所以我假设您使用引导程序,我看不到您告诉模态关闭的任何地方。

您可以在提交表单时以编程方式关闭模式:

 $(document).ready(function(){
 $("#register-form").submit(function(){

 $('#register').modal('hide');

 var str = $(this).serialize();
  $.ajax({
    type: "POST",
    url: "register_process.php",
    data: str,
    success:function(result){
      $(" #register .modal-body").load('login_succesful.php');
    }
  });
  return false;
 });
 });
于 2013-08-11T13:17:51.760 回答