title: Prevent modal from closing when error submitting the form (jQuery)
body: <p>So basically I have a bootstrap modal with a form:</p>
  <h3>html:</h3>
  <pre><code>&lt;div id=&quot;modal&quot; class=&quot;modal fade&quot; role=&quot;dialog&quot;&gt;
      &lt;div class=&quot;modal-dialog&quot;&gt;
          &lt;div class=&quot;modal-content&quot;&gt;
              &lt;div class=&quot;modal-header&quot;&gt;
                  &lt;!-- some heading here --&gt;
              &lt;/div&gt;
              &lt;div class=&quot;modal-body&quot;&gt;
                  &lt;form class=&quot;form-partner&quot;&gt;
                      &lt;!-- some form here --&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
              &lt;div class=&quot;modal-footer&quot; style=&quot;text-align:center;&quot;&gt;
                  &lt;div id=&quot;message&quot;&gt;&lt;/div&gt;
                  &lt;button class=&quot;btn btn-lg&quot; type=&quot;submit&quot; id=&quot;submit&quot;&gt;BUTTON&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p>And a jQuery script that sends it to <em>send.php</em>, where the data is being checked and submitted to the server.</p>
  <h3>js</h3>
  <pre><code>$(function() {
      $(&quot;#submit&quot;).click(function(){
          $.ajax({
              type: &quot;POST&quot;,
              url: &quot;send.php&quot;,
              data: $('form').serialize(),
              success: function(msg){
                  $(&quot;#message&quot;).html(msg)
                  //$(&quot;#modal&quot;).modal('hide'); 
              },
              error: function(){
                  alert(&quot;failure&quot;);
              }
          });
      });
  });
  </code></pre>
  <p>I write an error message to the <em>div#message</em>, but I need it to close the modal whenever the submission is successful.</p>
  <p>Is there a way to do that, like can I check the data validity (like if email is actually an email) in jQuery <em>$.ajax</em> itself?</p>