inserting Ajax into an appended ul
First off here's the code:
-
function getLastPost(id,reply){
var isReply = (reply != undefined) ? "&reply="+reply:"&reply=0";
$.ajax({
type: "GET",
url: "./ajaxphp/getPosts.php",
data: "amount=1&ID="+id+isReply,
dataType: "html",
success: function(data){
if(reply != undefined){
if(!$("#post-"+id+" > ul").hasClass("postReply")){
$("#post-"+id).append("<ul class=\"postReply\"></ul>");
}
$(data).hide().prependTo("#post-"+id+" > ul.postReply");
}else{
if(!$("#postMain").hasClass("postEntry")){
$("#postMain").append("<ul class=\"postEntry\"></ul>");
}
$(data).hide().prependTo("ul.postEntry");
}
$("#post-"+id).fadeIn("slow");
jsReply();
}
});
}
So basically what this function is doing is getting an <li> of data and inserting it into a <ul>. However, if that ul isn't there it will append one. The "id" variable gets the id of the post and inserts it into ul.postEntry, however if the post is a reply to another it will create a ul.postReply within the parent post and put the <li> data into that. Everything in the "else" clause of the conditional works fine. It's just this line that will not work
-
if(!$("#post-"+id+" > ul").hasClass("postReply")){
$("#post-"+id).append("<ul class=\"postReply\"></ul>");
}
This conditional checks if there is a ul.postReply and if not make one. I checked it with an alert, and the conditional fires off properly however the append part never works which is weird because the other append works fine. What am I doing wrong?