$('.chat').submit(function() {
$.post("", $(this).serialize(), function(response) {
$(this).closest('.stake_chat').prepend(???);
});
return false;
});
Where ??? is I would like to output the chat message, the name=”chat_message” field in the form.
The post serializes the forms data and pass it to the same site; I need the data of name=”chat_message” to prepend in the .stake_chat class.
Inside the AJAX success callback
thisis not what you think it is. It is not the form. It represents the xhr object. You could capture the form in a closure if you want to use it inside the callback:or use the context parameter with
$.ajax:And to get the input that’s inside the form with a given name you could use the following selector: