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(); }); 
  • event submit handled? - Sonic Myst
  • @SonicMyst seems like no. how to check? - user317795
  • Open the developer console and look into it all eyes. - u_mulder
  • somewhere in the function body, register console.log ('check') is the easiest way, and look in the developer console. - Sonic Myst
  • @SonicMyst looked at the console, nothing happens - user317795

0