Submiting for using ajax and php and return response
<p>I am using this php to submit a form and is working now i want to post to it using ajax and return what i have submitted without reloading the page but is not posting to me database and it not showing me errors.
Which other simple way can i archive this or can anyone show me where am doing it wrong 
Here is the full program <code>&lt;?php echo $_GET['postid'];?&gt;</code> &lt; this get ID of my main blog post
<strong>HTML STRUCTURE</strong></p>

<pre><code>&lt;form id="add-comment" action="javascript:void(0);" style="font-size: 100%;"&gt;
&lt;textarea placeholder="" name="comment" cols="68" rows="3" style="min-height:30px;" id="comment"&gt;&lt;/textarea&gt;
&lt;?php 
if(!isset($_SESSION['user_login'])) { 
echo "&lt;label&gt;Enter name&lt;/label&gt;&lt;br&gt;";
echo "&lt;input placeholder='Enter a name' style='width:130px;height: inherit;' required='true' id='anony' type='text' name='name'/&gt;";
}?&gt;
&lt;input tabindex="0" value="Add Comment" class="btnpostq" id="donedbtn" type="submit"/&gt;
&lt;input type="hidden" value="&lt;?php echo $_GET['postid'];?&gt;" name="rid"/&gt;
&lt;/form&gt; 
</code></pre>



<p><strong>Ajax</strong></p>



<pre><code>&lt;script&gt;
$(document).ready(function(){
    $('#add-comment').submit(function(){

        $('#response').html("&lt;b&gt;Loading response...&lt;/b&gt;");
        $.ajax({
            type: 'POST',
            url: 'alter_reply.php', 
        data:'comment='+comment+'&amp;name='+name+'&amp;rid='+rid,
        })
        .done(function(data){

            $('#response').html(data);

        })
        .fail(function() {

            alert( "Posting failed." );

        });
        return false;

    });
});
&lt;/script&gt;
</code></pre>

<p><strong>alter_reply.php</strong></p>

<pre><code>&lt;?php

if($_POST) {
$db_host = "localhost";
$db_user = "root";
$db_pass = "";
$db_name = "post";

     try {
     $db_conn = new PDO("mysql:host={$db_host};dbname={$db_name}",$db_user,$db_pass);
     $db_conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $stmt = $db_conn-&gt;prepare("INSERT INTO replys(rid,mesreplys,rtime,rusername) VALUES(:rid,:mesreplys,:rtime,:rusername)");


$stmt-&gt;bindParam(':rid', $rid); 
$stmt-&gt;bindParam(':mesreplys', $comment);
$stmt-&gt;bindParam(':rtime', $timedate); 
$stmt-&gt;bindParam(':rusername', $user); 



$form = $_POST;
$rid= $form['rid'];
$comment = $form['comment'];
$timedate = date("Y-m-d H:i:s");
if(isset($_SESSION['user_login'])){
$user = $_SESSION['user_login'];
}else{
$anony_user = $form['name'];
$user = $anony_user;    
}   

    $stmt-&gt;execute();

    }
catch(PDOException $e)
    {
    echo "Error:" . $e-&gt;getMessage();
    }
$db_conn = null;
}
?&gt; 
</code></pre>