mirror of
https://github.com/FAUSheppy/flask-json-dream-website
synced 2025-12-09 17:18:33 +01:00
implement basic functionality of contact via form->smtp
This commit is contained in:
35
static/contact.js
Normal file
35
static/contact.js
Normal file
@@ -0,0 +1,35 @@
|
||||
function submitForm(){
|
||||
|
||||
/* show the waiting dialog */
|
||||
dialog = document.getElementById("waiting-dialog")
|
||||
dialog.style.disply = "block"
|
||||
setMainBackgroundOpacity(0.5)
|
||||
|
||||
/* submit the form */
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "/your/url/name.php");
|
||||
xhr.onload =
|
||||
formData = new FormData(document.getElementById("contact-form"));
|
||||
xhr.send(formData);
|
||||
|
||||
mainContainer = document.getElementById("main-container")
|
||||
mainContainer.style.opacity = 0.5
|
||||
|
||||
window.location.href = "/thanks"
|
||||
// after x seconds forward to thx
|
||||
|
||||
}
|
||||
|
||||
function formSubmitFinished(event){
|
||||
if(event.target.status != 200){
|
||||
showErrorMessage(); // blocking
|
||||
setMainBackgroundOpacity(0.5)
|
||||
}else{
|
||||
window.location.href = "/thanks"
|
||||
}
|
||||
}
|
||||
|
||||
function setMainBackgroundOpacity(opacity){
|
||||
mainContainer = document.getElementById("main-container")
|
||||
mainContainer.style.opacity = opacity
|
||||
}
|
||||
Reference in New Issue
Block a user