I have a comment's reply form which is loop through database, each of the form and reply button are dynamically assigned with difference ID, such as <button type="button" id="btn_reply_comment_'.$row['id'].'">Post Reply</button>
as well as a form ID with <form id="reply_form_'.$row['id'].'">
.
I want to make an ajax call trigger by the #btn_reply_comment_{follow by dynamic ID}
, but I cannot assign dynamic ID to match with which button is clicked, how can it be done?
Jquery to trigger ajax by button click:
$('body').on('click', '#btn_reply_comment_'+id, function(){
var parameters = $(this).closest('form').serialize();
alert(parameters);
//ajax call here
});