I've a page in which I've posts and users are to give comments. The comments are handled using AJAX. Each comment line has a "Vote" button.
In the index page, I've put the jQuery function for the vote
<script type="text/javascript">
$(function() {
$('.voteUpBtn').click(function() {
// Cast your vote
}
}
</script>
Now when a user submits a new comment, it makes an AJAX call and appends the HTML using jQuery to the index page
$.ajax({
type: "POST",
url: "proc/add-line.php",
data: dataString,
cache: false,
success: function(html){
$("ul#nextLines").append(html);
}
});
On the appended HTML, I have the same vote button. (Each comment has a corresponding vote button).
The Problem is, the "vote" button on the new comment generated by AJAX doesn't work. If I refreshed the page, the vote works (although I'm using the same Markup).
How do I make it possible for the vote button to work in the AJAX returned HTML??