Jump to content

Recommended Posts

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 using something like

 

$.ajax({
type: "POST",
url: "../include/comment_ajax.php",
data: dataString,
cache: false,
success: function(html){
$("#Loadnewcomment"+Id).append(html);
$(".oldcommenthide"+Id).hide(), $(".newcomment"+Id).show();
}
});

 

Now in that comment_ajax.php let's say there is another like or comment input field, something like.

 

<div class=\"Likecomment\">
                                <div id=\"likehide\" class=\"likehide$commentID$CommentIDLike\">
                                    <form method=\"post\" name=\"$commentID$CommentIDLike\" action=\"\">
                                    <input type=\"hidden\" id=\"PostID$commentID$CommentIDLike\" value=\"$PostID\" />
                                    <input type=\"hidden\" id=\"UserPostID$commentID$CommentIDLike\" value=\"$PostUserID\" />
                                    <input type=\"submit\" class=\"likepost\" id=\"$commentID$CommentIDLike\" value=\"Like\" />
                                   </form>
                                   </div>";

 

How would I get this form to also use the ajax that is on the original page, because this is loaded in thru the ajax, so it doesn't know to use the normal ajax. My likes work perfectly, unless I create a new comment, then on that new comment, if I click "Like" on a comment, rather than it just changing, it reloads the page, then I can click like on it like normal and it changes using my ajax, but not until the page is reloaded.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.