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 に答える