JSFiddle - React, Tailwind, and code Playground

by Michele Marcucci

HTML

<form method="post" class="myform">
    <input type="text" name="firstname" placeholder="Vorname" required>
    <br>
    <input type="text" name="lastname" placeholder="Nachname" required>
    <br>
    <input type="text" name="nickname" placeholder="Spitzname" required>
    <br>
    <input type="email" name="email" placeholder="Email" required>
    <br>
    <input type="submit" value="Speichern">
</form>

JavaScript

$('.myform').submit(function () {
    $.ajax({
        url: "insert.php",
        data: $(this).serialize(),
        type: "post",
        success: function(output) {
            // do stuff
        }
    });   
});