title: How to close a bootstrap modal and redirect after success-alert displayed
body: <p>I'm new to javascript/programming and I'm having trouble trying to close a bootstrap modal after a form submission returns with a alert-success message.  What I'd like to happen is for the user to: </p>
  
  <ol>
  <li>submit a form embedded in the modal.  </li>
  <li>If successfully submitted,the alert-success message will display.  </li>
  <li>If the alert-success displays, I'd like to have the modal window close</li>
  <li>(optionally) I'd like to reset the form</li>
  </ol>
  
  <p>I've tried using javascript hide function but no luck. </p>
  
  <pre><code>$(document).ready(function(){
    if($('#alert-success'))
    {
     $('#myModal').hide();
    } 
  
  });
  </code></pre>
  
  <p>Any help would be appreciated! </p>
  
  <p>Here is a sample code of what I'm trying to create (note: I've including dummy code since I don't have permission to use my company code here). link to code below found here also: <a href="http://jsbin.com/pidizetila/edit?html,output" rel="nofollow">http://jsbin.com/pidizetila/edit?html,output</a></p>
  
  <pre><code>&lt;!-- Trigger the modal with a button --&gt;
      &lt;button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal"&gt;Open Modal&lt;/button&gt;
  
  &lt;!-- Modal --&gt;
      &lt;div id="myModal" class="modal fade" role="dialog"&gt;
        &lt;div class="modal-dialog"&gt;
  
      &lt;!-- Modal content--&gt;
  
  
       &lt;div class="modal-content"&gt;
            &lt;div class="modal-header"&gt;
              &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;      &lt;/button&gt;
              &lt;h4 class="modal-title"&gt;Modal Header&lt;/h4&gt;
            &lt;/div&gt;
            &lt;div class="modal-body"&gt;
              &lt;div class="alert alert-success"&gt;
        &lt;strong&gt;Success!&lt;/strong&gt; Indicates a successful or positive action.
      &lt;/div&gt;
            &lt;/div&gt;
  
          &lt;/div&gt;
  
        &lt;/div&gt;
      &lt;/div&gt; 
  </code></pre>