bigly-chat/static/main.js

24 lines
531 B
JavaScript
Raw Normal View History

2024-11-25 14:12:43 -05:00
async function formClick(ev) {
ev.preventDefault();
let { target } = ev;
let fetched = await fetch(target.action, {
'method': 'POST',
'body': new FormData(target)
});
let json = await fetched.json();
document.querySelector('.form-message').textContent = json.message;
if (json.redirect) {
setTimeout(function () {
window.location.href = json.redirect;
}, 2000);
}
}
window.onload = function () {
document.addEventListener('submit', formClick);
}