Since you are already caching the allocation of $(this) in the variable $form , just reference it instead of using $(this) everywhere:
$('document').ready(function () { $("form").on("submit", function (e) { e.preventDefault(); var $form = $(this), commentbox = $form.children('.commentBox'); $.ajax({ url : $form.attr("action"), data : $form.serialize(), type : $form.attr("method"), success : function (response) { commentbox.val(''); $form.closest('.commentContainer').append(response);
UPDATE
Thanks for submitting your HTML, it seems that the .commentContainer element is a child of the form element, so you want to change:
$form.closest('.commentContainer').append(response);
To:
$form.siblings('.commentContainer').append(response);
source share