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