JSFiddle - React, Tailwind, and code Playground
HTML
<form id="form1" method="post" action="" onsubmit="doSomething(this, event)">
<input type="hidden" value="1" name="comentonpost" id="comentonpost" />
<textarea class="commentinput" name="body" id="body" cols="20" rows="5"></textarea>
<input type="submit" id="submit" value="Submit" />
</form>
JavaScript
var working = false;
function doSomething(elm, e) {
var form = elm,
x = form.comentonpost.value,
submit = form.submit;
e.preventDefault();
if (working) return false;
working = true;
submit.value = 'working..';
$('span.error').remove();
$.post('/echo/json/', $(form).serialize(), function (msg) {
working = false;
submit.value = 'submit';
alert(x);
$(msg.html).hide().insertBefore('#addCommentContainer' + x).slideDown();
}, 'json');
}