0
我正在尝试向旧评论框添加新评论。 这里是我的代码,不知道为什么它不工作向旧评论组添加新评论
<script type="text/javascript">
$(document).ready(function() {
$(function() {
$(".bsubmit").click(function() {
var id = $(this).parent().parent().attr("id");
var comm = document.getElementById(id).getElementsByClassName("commentadd")[0].value;
$.ajax({
type: "POST",
url: "comment.php",
data: {
id: id,
comm: comm
},
cache: false,
success: function() {
$('.addcomment').slideUp('slow', function() {
// POSTED IN DATABASE SUCCESS NOW APPEND The comment with other COMMENTS
document.getElementById(id).getElementsByClassName(".itemcomment").append('<div class="comm">
<a href="profile.php?id=<?php echo $_SESSION['
fbid ']; ?> class="comm_img"><img src=" <?php echo $_SESSION['
smallest ']; ?> width="50" height="50" /></a>
<p width="50"><strong>
</strong></p>
</div>');
});
$('#load').fadeOut();
}
});
return false;
});
});
});
</script>
尝试使用'$(“#div_id .itemcomment”)'而不是'document.getElementById(id).getElementsByClassName(“。itemcomment”)'。 – Karo
@David - 但是当PHP执行时,这将写入javescript。 假设存储在一个变量中。现在我只是追加变量的值..不是吗? – Yahoo
@Karo - 我的Div_ID位于一个名为ID的变量中。我怎么可以重新创建该声明? 谢谢 – Yahoo