title: ajax comment form not posting data to mysql
body: <p>I am using ajax to post a comment to a mysql table.  When I post the comment, the javascript is loading but it doesnt submit the data to the mysql database.</p>
  
  <pre><code>$(document).ready(function(){
     $('#commentform').on('submit',function(e) {
        $.ajax({
           url:'ajax.php',
           data:$(this).serialize(),
           type:'POST',
           success:function(data){
              console.log(data);
              $("#success").show().fadeOut(5000);
           },
           error:function(data){
              $("#error").show().fadeOut(5000);
           }
        });
  
        e.preventDefault();
     });
  });
  </code></pre>
  
  <p>ajax.php</p>
  
  <pre><code>$id =   $_POST['id'];
  $comment    =   $_POST['comment'];
  $username   =   $_POST['username'];
  
  $array = $pdo-&gt;prepare("INSERT INTO `comments` (id, comment, user)
  VALUES (:id,:comment,:username);");
  $array-&gt;execute(array(':id' =&gt; $id, ':comment' =&gt; $comment, ':username' =&gt; $username));
  </code></pre>
  
  <p>html</p>
  
  <pre><code>&lt;form method="post" name="commentform" id="commentform"&gt;
     &lt;textarea name="comment" name="comment"&gt;&lt;/textarea&gt;&lt;br&gt;
     &lt;input type="hidden" value="&lt;?php echo "$id"; ?&gt;" name="id" id="id" /&gt;
     &lt;input type="hidden" value="&lt;?php echo "$username"; ?&gt;" name="username" id="username" /&gt;
     &lt;input type="submit" name="submit" id="submit" value="REPLY" /&gt;
  &lt;/form&gt;
  </code></pre>