How to post data in ajax from bootstrap modal?
<p>I have a problem in bootstrap modal. I want to add caption of an image using bootstrap model.</p>

<p>For the modal section I have done this,</p>

<pre><code>&lt;!-- Modal content Start--&gt;
 &lt;form method="POST"&gt;
   &lt;!-- Modal --&gt;
   &lt;div class="modal fade" id="myModal&lt;?php echo $i;?&gt;" role="dialog"&gt;
     &lt;input type="hidden" id="image_id" name="image_id" value="&lt;?php echo $Array-&gt;image_id;?&gt;" &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;Image Caption&lt;/h4&gt;
          &lt;/div&gt;
          &lt;div class="modal-body"&gt;
            &lt;input type="text" id="caption" name="caption" placeholder="Caption" value="&lt;?php echo $Array-&gt;image_caption;?&gt;"/&gt;
          &lt;/div&gt;
          &lt;div class="modal-footer"&gt;
            &lt;button class="btn btn-success" id="btn_caption"&gt;submit&lt;/button&gt;
            &lt;a href="#" class="btn" data-dismiss="modal"&gt;Close&lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/form&gt;
&lt;!-- Modal End Here  --&gt;
</code></pre>

<p>For the ajax part I have done this,</p>

<pre><code>$(document).ready(function(e) {
  $("button#btn_caption").click(function(){
    var postData = $(this).serialize();
     alert(postData);
     $.ajax({
       type: "POST",
       url: "process.php",
       data: postData,
        success: function(msg){
            //alert('successfully submitted')
        },
        error: function(){
          alert("failure");
        }
    });
  });
});
</code></pre>

<p>For the process.php file I put these lines,</p>

<pre><code>&lt;?php 
include('require/admin_header.php');
if (isset($_POST['caption'])) {
    $caption=strip_tags($_POST['caption']);
    $image_id=strip_tags($_POST['image_id']);
    echo '&lt;pre&gt;';
    print_r($_POST);
    // Data base update code
    echo 'Update Done';
}?&gt;
</code></pre>

<p>Now, the problem is the database is not updating with the value. <code>&lt;?php echo $Array-&gt;image_caption;?&gt;</code> it print the value from the database in the modal. But when I do this <code>alert(postData);</code>, it alert nothing. Can any one help me that where I am making the mistake?</p>

<p>Thanks in advance for help.</p>