I'm trying to put together a view more comments function. So my original post with the id of comment_streamitem is the original posts id and the comment_id is the comments id. I show two comments on the posts then an view all link shows.
I am currently able to get all the comments from the database through $_GET JSON array and it shows as such in Firebug. The comment_list_ID removes the two original comments and removes the view link but doesn't insert the 4 retrieved comments from the database the area where they should insert into its div stays blank.
Could someone look over my code for any possible oversights or errors please?
Thank you
<script type="text/javascript">
$(function()
{
$(".view_comments").click(function()
{
var ID = $(this).attr("id");
$.ajax({
type: "GET",
url: "viewmorecommentslink.php?comment_streamitem="+ ID,
success: function(data){
$("#comment_list_"+ID).append('<div id="comment_list_'+data['comment_streamitem']+'"><div class="stream_comment" id="comment_'+data['comment_id']+' style="margin-top:0px; background-color:#000000;"><table width=100%><tr><td valign=top width=30px><img class="stream_profileimage" style="border:none;padding:0px;display:inline;" border=\"0\" src=\"userimages/cropped'+data['comment_poster']+'.jpg\" onerror=this.src=\"userimages/no_profile_img.jpeg\" width=\"40\" height=\"40\" ></a><td valign=top align=left>\
<a href="/profile.php?username='+data['username']+'">'+data['first']+' '+ data['middle']+' '+data['last']+'</a> - <abbr class="timeago" title="'+data['comment_datetime']+'">'+data['comment_datetime']+'</abbr><div class="commentholder">'+data['comment_content']+'</div><br/>\<div id="commentactivitycontainer"><a style="cursor:pointer;" onClick=\"deletecomment('+data['comment_id']+',comment_'+data['comment_id']+');\">Delete</a><a id="likecontext_'+data['comment_id']+'" style="cursor:pointer;" onClick=\"likestatuscomment('+data['comment_id']+',this.id);\"><div style="width:80px; position:relative; float:left; left:40px" id="likescommentprint'+data['comment_id']+'">Like</div></a><div style="width:80px; position:relative; float:left; left:40px" id="likescommentprint'+data['comment_id']+'"></div></form>\
<a id="dislikecontext_'+data['comment_id']+'" style="cursor:pointer;" onClick=\"dislikestatuscomment('+data['comment_id']+',this.id);\"><div style="width:90px; position:relative;top:-0px; float:left; left:200px" id="dislikescommentprint'+data['comment_id']+'">Dislike</div></a><div style="width:90px; position:relative; top:-0px; float:left; left:200px" id="dislikescommentprint'+data['comment_id']+'"></div></form></div></div></table></div></div></div></div></table></div></div>');
$("#view"+ID).remove();
$("#comment_list_"+ID).remove();
}
});
return false;
});
});
</script>
Viewcommentslink.php
<?php
require"include/rawfeeds_load.php";
if(isset($_GET['comment_streamitem'])){
$id=$_GET['comment_streamitem'];
$check = "select comment_id,comment_poster,comment_streamitem,comment_datetime,comment_content FROM streamdata_comments WHERE comment_streamitem='$id' order by comment_id";
$check1 = mysqli_query($mysqli,$check) or die(mysqli_error($mysqli));
while($resultArr = mysqli_fetch_array($check1))
{
$json['comment_id'] = $resultArr['comment_id'];
$json['comment_poster'] = $resultArr['comment_poster'];
$json['comment_streamitem'] = $resultArr['comment_streamitem'];
$json['comment_datetime'] = $resultArr['comment_datetime'];
$json['comment_content'] = $resultArr['comment_content'];
$user=$resultArr['comment_poster'];
$check2= "SELECT * FROM user WHERE id='$user'";
$check22 = mysqli_query($mysqli,$check2);
$resultArr = mysqli_fetch_array($check22);
$json['username'] = $resultArr['username'];
$json['id'] = $resultArr['id'];
$json['first'] = $resultArr['first'];
$json['middle'] = $resultArr['middle'];
$json['last'] = $resultArr['last'];
echo json_encode($json);
}}