Ok, so I have a few ajax pieces on my site, and I am trying to include functionality when something is clicked. Basically, lets say like on facebook, when someone makes a comment, then that new comment is created.
My return is for the pieces with the ID's pulling in, as you can see, each one is unique, and the first one won't work after it is pulled in thru the original ajax request, it just reloads the page once first, then after the page is reloaded and it has the same exact code as before, then it works, but it's like it doesn't do the ajax piece when it's pulled from the url: "../include_wall_front/likepost_ajax.php", because the document can't be ready I guess thru the DOM "$(document).ready(function()" since this is loaded thru ajax? Do you see any difference in Like80 to Like79? Because Like 79 works, but Like80 refreshes, then it works after the refresh, but if I make another Post, then it would ad another Like - Like81 but that one wouldn't work until it's reloaded. Does that make sence?
<div class="Like">
<div id="Like80" class="flash_load"></div>
<div id="loadLike80"></div>
<div id="likehide" class="likehide80">
<form method="post" name="80" action="">
<input id="PostID80" value="80" type="hidden">
<input id="UserPostID80" value="1" type="hidden">
<input id="Friend80" value="0" type="hidden">
<input class="likepost" id="80" value="Like80" type="submit">
</form>
</div>
<div class="unlikehide80" style="display: none;">
<form method="post" name="80" action="">
<input id="PostID80" value="80" type="hidden">
<input id="Friend80" value="0" type="hidden">
<input id="UserPostID80" value="1" type="hidden">
<input class="unlikepost" id="80" value="Unlike" type="submit">
</form>
</div>
</div>
<div class="Like">
<div id="Like79" class="flash_load"></div>
<div id="loadLike79"></div>
<div id="likehide" class="likehide79">
<form method="post" name="79" action="">
<input id="PostID79" value="79" type="hidden"><input id="Friend79" value="0" type="hidden"><input id="UserPostID79" value="1" type="hidden">
<input class="likepost" id="79" value="Like79" type="submit">
</form>
</div><div class="unlikehide79" style="display: none;">
<form method="post" name="79" action=""><input id="Friend79" value="0" type="hidden">
<input id="PostID79" value="79" type="hidden">
<input id="UserPostID79" value="1" type="hidden">
<input class="unlikepost" id="79" value="Unlike" type="submit">
</form>
</div>
</div>
and my ajax is
$(document).ready(function()
{
$(".likepost").click(function(){
var element = $(this);
var Id = element.attr("id");
var $PostID = $('#PostID'+Id).val();
var $UserPostID = $('#UserPostID'+Id).val();
var $Friend = $('#Friend'+Id).val();
var dataString = 'PostID=' + $PostID + '&UserPostID=' + $UserPostID + '&Friend=' + $Friend;
$.ajax({
type: "POST",
url: "../include_wall_front/likepost_ajax.php",
data: dataString,
cache: false,
success: function(html){
$("#loadLike"+Id).append(html);
$(".likehide"+Id).hide(), $(".unlikehide"+Id).show();
}
});
return false;
});
});
How would I get the Likes that are pulled in after the document is already loaded to work? These next likes, and I'll also have a delete post that won't work from the actual user unless the page is refreshed.
Thanks