title: How do I close Modal Popup on form submit?
body: <p>I have a modal popup to change the password and I need to close it on submit button. </p>
  
  <pre><code>&lt;div class="modal-body"&gt; 
      &lt;?php if(isset($message))echo '&lt;span class="text-success txt-upper" style="margin-left:2rem;"&gt;'. $message .'&lt;/span&gt;';?&gt;
  
      &lt;?php echo form_open('',array('class'=&gt;'ajaxForm')); ?&gt;
        &lt;fieldset class="table "&gt; 
          &lt;div class="form-group"&gt;
          &lt;?php $class = form_error('newpassword')?"input-error":"" ?&gt;
            &lt;div  class="col-md-12" style="margin: 10px 0"&gt;&lt;?php echo form_password('newpassword','','class="form-control margin-both-0 '. $class.'" id="newpassword"  placeholder="New Password" autocomplete="off"'); ?&gt;&lt;?php echo form_error('newpassword'); ?&gt;&lt;/div&gt;            
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
          &lt;?php $class = form_error('conpassword')?"input-error":"" ?&gt;
            &lt;div class="col-md-12 " style="margin: 10px 0"&gt;&lt;?php echo form_password('conpassword','','class="form-control  margin-both-0 '. $class.'" id="conpassword"  placeholder="Confirm Password" autocomplete="off"'); ?&gt;&lt;?php echo form_error('conpassword'); ?&gt;&lt;/div&gt;           
          &lt;/div&gt;  
  
  &lt;/div&gt;
  &lt;div class="modal-footer"&gt;
          &lt;?php echo form_submit('submit_btn', 'Change Password', 'class="submit btn btn-success margin-left-4p pad-1-rem margin-bottom-10"'); ?&gt;
       &lt;/fieldset&gt;
      &lt;?php echo form_close();?&gt;  
    &lt;/div&gt;
  </code></pre>
  
  <p>The above code is the form submit button.</p>
  
  <pre><code>$(function() {
          $(".submit").click(function(e){
              var sdata = $('.ajaxForm').serialize();
              $.ajax({
                  type: "POST",
                  data:sdata,
                  url: "&lt;?php echo site_url('home/change_password'); ?&gt;",
                  success: function(data){
                      $('#baseModal-xs .modal-content').html(data);  
                  }
              });
              return false;
          });
      });
  
  &lt;script type="text/javascript"&gt;
      $(".submit").ajaxForm(function() { 
          window.close();
      });
  </code></pre>
  
  <p></p>
  
  <p>This is the javascript I have added the windows.close function isn't working</p>