title: Edit data in bootstrap modal
body: <p>After searching here for a while I decided to ask my own question, even if it is similar to some others.</p>
  
  <p>I'd like to pass an id to a bootstrap modal. Inside the modal, a form should be populated with data based on this id and then submitted. After submitting, the "thank you" message should also appear in the modal (or the first one should be closed and the second one opened).</p>
  
  <p>I found quite some ideas here, but due to my limited understanding of jQuery and Ajax I'm unable to come up with a solution.</p>
  
  <p>The buttons:</p>
  
  <pre><code>&lt;a class="btn..." data-toggle="modal" data-target="#myModal" data-id="1"&gt;First Item&lt;/a&gt;
  &lt;a class="btn..." data-toggle="modal" data-target="#myModal" data-id="2"&gt;Second Item&lt;/a&gt;
  </code></pre>
  
  <p>The modal:</p>
  
  <pre><code>&lt;div id="myModal" class="modal hide fade"&gt;
    &lt;div class="modal-header"&gt;
      &lt;button class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;
  
      &lt;!-- would be great to have data from my database already for the title --&gt;
      &lt;h3&gt;&lt;?php echo "$TitleBasedOnId"; ?&gt;&lt;/h3&gt; 
  
    &lt;/div&gt;
    &lt;div class="modal-body"&gt;            
        &lt;div id="modalContent"&gt;
  
           &lt;form id="editData" role="form" method="post"&gt;
           &lt;!--  Form should populated with data from my MySQL database --&gt;
           &lt;div class="form-group"&gt;
              &lt;div class="col-md-3"&gt;
                 &lt;label for="user"&gt;User:&lt;/label&gt; 
                 &lt;input class="form-control" name="user" type="text" id="user" value="&lt;?php echo '$UsernameBasedOnId'; ?&gt;" &gt;     
              &lt;/div&gt;
           &lt;/div&gt;
           ...
           &lt;button type="submit" class="btn..."&gt;Edit User&lt;/button&gt;
           &lt;/form&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="modal-footer"&gt;
      &lt;a href="#" class="btn btn-info" data-dismiss="modal" &gt;Close&lt;/a&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>After submitting the form, I'd like a "thank you" message in the same or a new modal.</p>
  
  <p>The jQuery:</p>
  
  <pre><code>/* no idea */
  </code></pre>
  
  <p>Thanks for your help!</p>