JSFiddle - React, Tailwind, and code Playground
HTML
<form method="post" id="kontakt">
<h3 class="title">Nur nicht schüchtern !</h3>
<input type="text" name="von" placeholder="Name" id="von">
<input type="text" name="mail" placeholder="E-mail" id="mail">
<textarea name="message" placeholder="Nachricht" id="nachricht"></textarea>
<input id="submit" type="button" value="senden">
</submit>
</form>
<div id="response"></div>
CSS
<?php
$data=$_POST['serialize'];
$von=$data['von'];
$mail=$data['mail'];
$nachricht=$data['nachricht'];
?>
JavaScript
$(document).ready(function () {
$("#submit").click(function () {
if ($("#von").val() == "" || $("#mail").val() == "" || $("#nachricht").val() == "") {
$("#response").html("bitte fülle alle felder aus!");
} else {
$("#response").html("Lade...");
$.ajax({
type: "POST",
data: $('#kontakt').serialize(),
url: "/echo/json/",
success: function (msg) {
alert(msg);
$("#response").html(msg);
}
});
}
});
});