Split up static files into static and django_static
This commit is contained in:
parent
3a9b2c25e7
commit
0f4b1d9da2
22 changed files with 9 additions and 4 deletions
34
static/js/custom_form.js
Normal file
34
static/js/custom_form.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// elements
|
||||
let customForm = document.getElementById("customform");
|
||||
let statusInfo = document.getElementById("statusinfo");
|
||||
let submitButton = document.getElementById("submitbtn");
|
||||
// event listener for deposit form
|
||||
// this implements a custom submit method
|
||||
customForm.addEventListener("submit", (event) => {
|
||||
submitButton.disabled = true;
|
||||
event.preventDefault(); // Don't do the default submit action!
|
||||
let xhr = new XMLHttpRequest();
|
||||
let formData = new FormData(customForm);
|
||||
xhr.addEventListener("load", (event) => {
|
||||
status_ = event.target.status;
|
||||
response_ = event.target.responseText;
|
||||
if (status_ == 200 && response_ == "success") {
|
||||
statusInfo.innerText = "Success. Redirecting soon.";
|
||||
window.location.replace("/");
|
||||
}
|
||||
else {
|
||||
statusInfo.classList.add("errortext");
|
||||
statusInfo.innerText = "An error occured. Redirecting in 5 seconds...";
|
||||
window.setTimeout(() => { window.location.replace("/") }, 5000);
|
||||
}
|
||||
})
|
||||
xhr.addEventListener("error", (event) => {
|
||||
statusInfo.classList.add("errortext");
|
||||
statusInfo.innerText = "An error occured. Redirecting in 5 seconds...";
|
||||
window.setTimeout(() => { window.location.replace("/") }, 5000);
|
||||
})
|
||||
xhr.open("POST", customForm.action);
|
||||
xhr.send(formData);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue