title: jQuery .submit() for comment form
body: <p>I have a looping comment form which contain also all user's posts, like Facebook. When I click the first comment form on the first loop the jQuery + ajax works fine but the rest loop does not work. It refresh the page. I've tried the following codes below but still same result. Any solution how to fix this issue?</p>
  <p><strong>jQuery Code Test 1</strong><br/></p>
  <pre><code>$('#comment_form').submit(function(e) { 
    $.post('inc/process-form', $(this).serialize(), function(results) { 
      $('.show-results').html(results).slideToggle().delay(2000).slideToggle(); 
        $('#comment_form')[0].reset(); 
      }); 
    event.preventDefault(); 
   });
  </code></pre>
  <hr />
  <p><strong>jQuery Code Test 2</strong><br/></p>
  <pre><code>$('#comment_form').submit(function() 
  { 
      event.preventDefault(); 
      $.ajax(
      { 
          beforeSend : function()
          {
              $('#show-results').html('Processing...'); 
          }, 
          url : 'inc/process-form', 
          type: 'POST', 
          data:(
          { 
              comment      : $('#content').val(), 
              pid          : $('#pid').val(), 
              date_comment : $('#date_comment').val() 
          }), 
          success : function(results) 
          { 
              $('.show-results').html(results).slideToggle().delay(2000).slideToggle(); 
              $('#comment_form')[0].reset(); 
          } 
      }); 
      return false; 
  }); 
  </code></pre>
  <hr />
  <p><strong>Comment Form on loop</strong><br/></p>
  <pre><code> &lt;form action=&quot;&lt;?= $do-&gt;form_url(); ?&gt;&quot; method=&quot;post&quot; id=&quot;comment_form&quot; class=&quot;comment&quot;&gt;
   &lt;input type=&quot;text&quot; name=&quot;comment&quot; placeholder=&quot;Give me high five&quot; maxlength=&quot;100&quot; id=&quot;comment&quot;/&gt;
   &lt;input type=&quot;hidden&quot; name=&quot;pid&quot; value=&quot;&lt;?= $post-&gt;pid; ?&gt;&quot; id=&quot;pid&quot;/&gt;
   &lt;input type=&quot;hidden&quot; name=&quot;date_comment&quot; value=&quot;&lt;?= $do-&gt;asia_date_time(); ?&gt;&quot; id=&quot;date_comment&quot;/&gt;
   &lt;button type=&quot;submit&quot;&gt;SEND&lt;/button&gt;
   &lt;/form&gt;
  </code></pre>
  <hr />
  <p>PHP CODE</p>
  <pre><code> if (isset($_POST['comment'])) : 
    $comment    = $do-&gt;is_empty($_POST['comment']); 
    $pid        = $do-&gt;is_empty($_POST['pid']); 
    $date_comment = $do-&gt;is_empty($_POST['date_comment']); 
    if (empty($comment)) { 
      $error = 'Comment should not be empty'; 
    } 
    if (!isset($comment{20})) { 
      $error = 'Comment should at least 20 character.'; 
    } 
    if (empty($error)) { 
      echo $db-&gt;insert_comment($comment, $_SESSION['uid'], $date_comment, $pid); 
    } else { 
      echo '&lt;p class=&quot;error&quot;&gt;' .$error .'&lt;/p&gt;'; 
    } 
   endif; 
  </code></pre>