我無法追加頁面似乎只是刷新在那裏,因爲我想查看它無需刷新頁面無法附加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