$(document).ready(function() { $('.comment-form').submit(function(e, data) { e.preventDefault(); let el = $(this); let id = el.data('id'); let commentform = el.find('input[name="comment"]'); let commenttext = commentform.val(); let item = {item: id, comment: commenttext}; try { axios.post('/i/comment', item); var comments = el.parent().parent().find('.comments'); var comment = '
' + pixelfed.user.username + ''+ commenttext + '
'; comments.prepend(comment); commentform.val(''); commentform.blur(); return true; } catch(e) { return false; } }); });