title: hide bootstrap modal after select redirect instead
body: <p>I would like to close my modalbox, so I return to the same page, after I click the "Select" button.</p>
  
  <p>I am on <code>shuffle.php</code>. I open the modalbox and call the code in <code>updaterecords.php</code>. When I click Select I should return to <code>shuffle.php</code>. The problem is right now that I am redirected to <code>updaterecords.php</code>. </p>
  
  <p>I try to solve that with adding this code to my AJAX call:</p>
  
  <pre><code>$('#editBox').on('hide.bs.modal', function (data) {
     $('#editBox').modal('hide')
  })
  </code></pre>
  
  <p>But I am still redirected. Is the code I added in the wrong place?</p>
  
  <p><strong>shuffle.php</strong></p>
  
  <pre><code>&lt;div class="modal-footer msg"&gt;
    &lt;form action="updaterecords.php" method="post"&gt;
      &lt;input type="hidden" id="fantasy-id" value="" name="id" /&gt;
      &lt;button type="submit" name="selectStore" &gt;Select&lt;/button&gt;
      &lt;button type="button" data-dismiss="modal"&gt;Close&lt;/button&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>updaterecords.php</strong></p>
  
  <pre><code>$(document).ready(function() {
    $(".btn-open-modal").click(function() {
      var id = $(this).data("id");
      $.ajax({
        type: 'post',
        url: 'getdata.php',
        data: {
          post_id: id
        }, 
        success: function(data) {
          console.log(data);
          var jdata = JSON.parse(data);
          if (jdata) {
            console.log("is json");
            $("#editBox").modal().show();
            $('#id').val(jdata.id);
            $("#editBox .modal-title").html(jdata.headline);
            $("#editBox .modal-body").html("Weekday: " + jdata.weekday + "&lt;br&gt;&lt;br&gt;Description: " + jdata.description); //  + " " + $query $query =&gt; query
  
            $('#editBox').on('hide.bs.modal', function (data) {
              $('#editBox').modal('hide')
            })
  
          } else {
            console.log("not valid json: " + data);
          }
        }
      });
    });
  }); 
  </code></pre>