try preventDefault
This commit is contained in:
parent
fe07147d6c
commit
3bf0f9d0e4
28
login.js
28
login.js
@ -4,19 +4,17 @@ window.addEventListener("DOMContentLoaded", init);
|
|||||||
|
|
||||||
function init (){
|
function init (){
|
||||||
let formSubmitButton = document.querySelector("#submit");
|
let formSubmitButton = document.querySelector("#submit");
|
||||||
formSubmitButton.addEventListener("click", loginFormSubmitHandler(e));
|
formSubmitButton.addEventListener("click", async (e) => {
|
||||||
}
|
e.preventDefault();
|
||||||
|
let form = document.querySelector("form");
|
||||||
async function loginFormSubmitHandler (e) {
|
let formData = new FormData(form);
|
||||||
e.preventDefault();
|
try {
|
||||||
let form = document.querySelector("form");
|
let ticket = await requestTicket(formData.get("username"), formData.get("password"));
|
||||||
let formData = new FormData(form);
|
await setTicket(ticket);
|
||||||
try {
|
window.location.href = "index.html";
|
||||||
let ticket = await requestTicket(formData.get("username"), formData.get("password"));
|
}
|
||||||
await setTicket(ticket);
|
catch (error) {
|
||||||
window.location.href = "index.html";
|
console.log(error);
|
||||||
}
|
}
|
||||||
catch (error) {
|
});
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user