Working version

This commit is contained in:
Adrian Amaglio 2020-08-27 14:34:23 +02:00
parent e6a699be6e
commit 384cb08dcc
2 changed files with 9 additions and 4 deletions

View File

@ -63,15 +63,20 @@ function jeanCloudContactFormIntercept (formId, theme) {
method: formElem.method, method: formElem.method,
body: new FormData(formElem) body: new FormData(formElem)
}) })
.then(data => { .then(data => {
loadingText.parentNode.removeChild(loadingText) loadingText.parentNode.removeChild(loadingText)
if (!data.ok || data.status == 500) { if (data.ok && data.status == 200) {
jeanCloudContactMailerMessage (messageBox, theme, 'error', 'Erreur du service denvoi. Réessayez plus tard ou contactez https://jean-cloud.net')
} else if (data.ok || data.status == 200) {
jeanCloudContactMailerMessage (messageBox, theme, 'success', 'Le message a bien été envoyé !') jeanCloudContactMailerMessage (messageBox, theme, 'success', 'Le message a bien été envoyé !')
formElem.reset() formElem.reset()
} else if (!data.ok && data.status == 500) {
jeanCloudContactMailerMessage (messageBox, theme, 'error', 'Erreur du service denvoi. Réessayez plus tard ou contactez https://jean-cloud.net')
} else if (!data.ok && data.status == 400) {
jeanCloudContactMailerMessage (messageBox, theme, 'error', 'Une erreur est survenue dans la requête que vous avez effectué. Réessayez plus tard ou contactez le webmaster par un autre moyen.')
// TODO display servers error message
} }
}) })
.catch((error) => { .catch((error) => {
loadingText.parentNode.removeChild(loadingText) loadingText.parentNode.removeChild(loadingText)
jeanCloudContactMailerMessage (messageBox, theme, 'error', 'Impossible denvoyer le formulaire. Vérifiez votre connexion internet ou réessayez plus tard.') jeanCloudContactMailerMessage (messageBox, theme, 'error', 'Impossible denvoyer le formulaire. Vérifiez votre connexion internet ou réessayez plus tard.')

View File

@ -6,7 +6,7 @@
</head> </head>
<body> <body>
<div id="contact-mailer-message"></div> <div id="contact-mailer-message"></div>
<form action="http://localhost:8080/submit" method="POST" id="contact-mailer-form"> <form action="https://mailer.jean-cloud.net/submit" method="POST" id="contact-mailer-form">
<input type="hidden" name="token" value="s0y6WANzU1XnYERoJxMwekP9pqilSVLK5Gbf3hmZadHB2rQ4u8" /> <input type="hidden" name="token" value="s0y6WANzU1XnYERoJxMwekP9pqilSVLK5Gbf3hmZadHB2rQ4u8" />
<div> <div>
<label for="nom">Votre nom&nbsp;:</label> <label for="nom">Votre nom&nbsp;:</label>