我无法追加页面似乎只是刷新在那里,因为我想查看它无需刷新页面无法附加jQuery的
的index.php
<div class="view_comment">
<b>username :</b> <?php echo $comment_comment;?>
</div>
<div id="comment_type_area" class="comment_type_area">
<form method="POST">
<input type="text" class="comment" post_id="<?php echo $shared_id2; ?>" id="text_comment" placeholder="Write a Comment"></input>
<input type="submit" id="post_button" ></input>
</form>
</div>
的jquery.js
$(document).ready(function(){
$('.comment').keydown(function (e){
if(e.keyCode == 13){
var post_id = $(this).attr('post_id');
var comment = $(this).val();
$.post('/comment.php',{ post_id: post_id, comment:comment});
$('.comment').val('');
/*i am guessing the problem starts from here and onwards*/
$(this).parent().children('.comments').append("<div class='view_comment'><b>Username :</b>" + comment +"</div>");
}
});
});
你确信没有JavaScript错误投掷到浏览器的控制台? –
表单提交... – epascarello
以及表单确实提交,因为我可以在我的数据库中看到它,我也能够从我的数据库 – jake123