Prompt, it is worth ajax-form to send data to the database. Only with the script the data is not sent, but without the script everything is fine. What is wrong with the script?
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 action="/" method="POST" id="FormID"> <input type="text" name="head" /> <input type="text" name="desc" /> <button type="submit" name="add">Добавить</button> <div id="FormStatus"></div> Js:
$("#FormID").submit(function(e) { var form = $(this); var url = form.attr('action'); $.ajax({ type: "POST", url: url, data: form.serialize(), success: function(data) { $('#FormStatus').text(data); } }); e.preventDefault(); });