diff options
-rw-r--r-- | juick-server/src/main/assets/scripts.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/juick-server/src/main/assets/scripts.js b/juick-server/src/main/assets/scripts.js index 289ccb43..19383e94 100644 --- a/juick-server/src/main/assets/scripts.js +++ b/juick-server/src/main/assets/scripts.js @@ -342,6 +342,22 @@ function showCommentForm(mid, rid) { return false; } submitButton.disabled = true; + e.preventDefault(); + let formData = new FormData(form); + fetch('/api/comment' + '?hash=' + document.getElementById('body').getAttribute('data-hash'), { + method: 'POST', + body: formData, + credentials: 'omit' + }).then(response => { + if (response.ok) { + return response.json(); + } + }).then(reply => { + window.location.href = new URL(`${mid}#${reply.rid}`, window.location.href); + window.location.reload(true); + }).catch(error => { + alert(error.message); + }) }); } reply.querySelector('.msg-comment textarea').focus(); |