Posting comment with ajax and jquery
Posted
by
Steve
on Stack Overflow
See other posts from Stack Overflow
or by Steve
Published on 2012-03-25T22:59:46Z
Indexed on
2012/03/25
23:29 UTC
Read the original article
Hit count: 286
I want to display the posted comment once the user comments. Just to add it under all of them as facebook does.
I have this:
// Interceptamos el evento submit
$('#CommentAddForm').submit(function() {
alert("entro");
alert($(this).attr('action'));
// Enviamos el formulario usando AJAX
$.ajax({
type: 'POST',
url: $(this).attr('action'),
data: $(this).serialize(),
// Mostramos un mensaje con la respuesta de PHP
success: function(data) {
$('#result').html(//????????????);
}
});
return false;
});
But i don't know very well how it works and i dont know what should i write in the line $('#result').html(//????????????);
The variable URL contains the route which inserts the comment in the DB. And it works well. Any idea? Thanks.
By the way, i have been reading this answer: Ajax/jQuery Comment System But i still don't get it.
© Stack Overflow or respective owner