I have below code. when I click reply link, it will show a comment box. I want 2 points. or give me best way to do my work.
- When 1 comment box open other must be hide.
- when I click on send button correct value should send vie serialize values.
These are the codes PHP code
<?PHP
for($i = 1; $i < 10; $i++)
{
?>
<div>comments text etc etc...</div>
<a href="" class="reply-comment"> Reply </a>
<div class="reply-comment-form" style="display:none;">
<form class="comment_form" method="post">
<textarea name="comment_box" rows="6" class="span10"></textarea> <br /><br />
<input type="button" onClick="send_comment()" class="btn btn-primary" value="send" />
</form>
</div>
<?PHP
}
?>
Jquery code
<script>
$(function(){
$('.reply-comment').on('click', function(e){
e.preventDefault();
$(this).next('.reply-comment-form').show();
});
});
function send_comment()
{
$.ajax({
type: "POST",
data : $('.comment_form').serialize(),
cache: false,
url: 'test.php',
success: function(data){
}
});
}
</script>
test.php file no need. I am checking values through firebug. please help me to clarify this problem. or give me best way to do my work.
I am stuck since 2 days. Thank you for your valuable time.