php dateien in php verzeichnis verschoben. message construct in eigene datei message.php verschoben.
This commit is contained in:
parent
c004ebe4db
commit
94e182a96e
11 changed files with 174 additions and 107 deletions
34
assets/js/bestellformular.js
Normal file
34
assets/js/bestellformular.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
window.onload = function () {
|
||||
document.getElementById('formular').addEventListener('submit', function (e) {
|
||||
e.preventDefault(); // Verhindert die Standard-Formularsendung
|
||||
const form = e.target;
|
||||
const data = new FormData(form);
|
||||
const notification = document.getElementById('notification');
|
||||
const btn = document.getElementById('bestellformular-btn');
|
||||
fetch(form.action, {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
body: data,
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
// Erfolgsnachricht anzeigen
|
||||
notification.textContent = 'Nachricht erfolgreich gesendet!';
|
||||
btn.className = 'submitbutton text-white mx-auto submit-after-valid-captchaaaa .fadeOut';
|
||||
// notification.className = 'bg-green-500 text-white px-4 py-2 rounded block';
|
||||
// setTimeout(() => notification.className = 'bg-green-500 text-white px-4 py-2 rounded hidden', 5000); // Benachrichtigung nach 5 Sekunden ausblenden
|
||||
})
|
||||
.catch((error) => {
|
||||
// Fehlermeldung anzeigen
|
||||
notification.textContent = 'Fehler beim Senden der Nachricht.';
|
||||
console.log(error);
|
||||
notification.className = 'bg-red-500 text-white px-4 py-2 rounded block';
|
||||
// setTimeout(() => notification.className = 'bg-red-500 text-white px-4 py-2 rounded hidden', 5000); // Benachrichtigung nach 5 Sekunden ausblenden
|
||||
});
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue