Add contanct form script

This commit is contained in:
Jens M. Sauer 2024-10-24 13:02:37 +02:00
parent 0958fb404d
commit fdcad5ff5e
2 changed files with 22 additions and 1 deletions

20
assets/js/contact.js Normal file
View File

@ -0,0 +1,20 @@
$(document).ready(function() {
$("#contactForm").on("submit", function(event) {
event.preventDefault(); // Verhindert das Standard-Formular-Submit
// AJAX-Anfrage senden
$.ajax({
url: 'contactform.php',
type: 'POST',
data: $(this).serialize(), // Alle Formulardaten serialisieren
success: function(response) {
// Rückmeldung anzeigen
$("#responseMessage").html(response);
},
error: function() {
// Fehlernachricht anzeigen
$("#responseMessage").html("Es gab einen Fehler beim Senden der Nachricht.");
}
});
});
});

View File

@ -6,6 +6,7 @@
{{ $util := resources.Get "js/util.js" }}
{{ $main := resources.Get "js/main.js" }}
{{ $demo := resources.Get "js/demo.js" }}
{{ $js := slice $jQuery $scrollex $scrolly $browser $breakpoints $util $main $demo | resources.Concat "js/bundle.js" | minify | fingerprint }}
{{ $contact := resources.Get "js/contact.js" }}
{{ $js := slice $jQuery $scrollex $scrolly $browser $breakpoints $util $main $demo $contact | resources.Concat "js/bundle.js" | minify | fingerprint }}
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}" async crossorigin="anonymous"></script>