top 10 boilerplate ever
This commit is contained in:
commit
153c74bd22
17 changed files with 567 additions and 0 deletions
0
static/main.css
Normal file
0
static/main.css
Normal file
24
static/main.js
Normal file
24
static/main.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue