title: Bootstrap modal opens upon successful form submit, but will not stay closed when "Close" button clicked
body: <p>I have a contact form that when submitted successfully, opens a Bootstrap modal letting the user know sending is successful.  It opens just fine upon success, but when I click close, it doesn't stay closed.  After a second or two it opens again and submits another form/message.  Please see code below.  I'm looping somewhere and thinking I am missing a "return" or "preventDefault()" somewhere.  Thanks!</p>
  
  <pre><code>$(document).ready(function() {    
  
  $(function() {
  
  // Get the form.
  var form = $('#ajax-contact');
  
  // Get the messages div.
  //var formMessages = $('#form-messages');
  
  $('#successModal').modal({
      show: false
  });
  
  $('#errorModal').modal({
      show: false
  });
  
  // Set up an event listener for the contact form.
  $("button").click(function(e) {
  
      // Stop the browser from submitting the form.
      e.preventDefault(e);
  
      // Serialize the form data.
      var formData = $(form).serialize();
  
      // Submit the form using AJAX.
      $.ajax({
          type: 'POST',
          url: $(form).attr('action'),
          data: formData,
          success: function(result){
              $('#contact-name').val('');
              $('#contact-email').val('');
              $('#contact-website').val('');
              $('#contact-message').val('');
  
              $('#successModal').modal({
                  show: true
              });
  
          },
          error: function(xhr,status,error){
              //$('#errorModal').modal('show')
          }
  
  
      });
  
  
  
  });
  
  
  
  });
  
  
  
  });
  </code></pre>