Why not send data with AJAX-script? : Tell me please, there is a form for sending data to the database. Without a script it works fine, but nothing happens with the script. In the console — Form Data has all the data, and the 200th code arrives, but is not added to the database.

PHP:

    <?php
    $data = $_POST;
    if ( isset($data['add']) )
    { $posts = R::dispense('posts');      
    $posts->head = $data['head'];
    $posts->desc = $data['desc'];
    R::store($posts);
    ?>

HTML:

    <form method="POST" id="FormID">
    <input type="text" name="head" required />
    <input type="text" name="head" required />

    <button type="submit" name="add">Добавить</button>

JS:

    <script>
    $("#FormID").submit(function(e) {
    var form = $(this);
    var url = form.attr('action');
    e.preventDefault();
    $.ajax({
    type: "POST",
    url: url,
    data: $("#FormID").serialize(),
    success: function(data) {
    c = "hello";
    $('#FormStatus').text(c);
    }
    });});
    </script>