Using these forms here send the POST data to the php variable?

  • There is a completely normal input tag. Therefore, work with them as with a completely normal HTML form with a POST request. - Alex Krass

1 answer 1

HTML

 <input id='dataTime' size="16" type="text" value="2012-06-15 14:45" readonly class="form_datetime"> 

JQUERY

  $.ajax({ url: 'datatime.php', data: { dataTime: $("#dataTime").val()}, method: 'post', dataType: 'json' success: function (res) { console.log(res.mess) } }) 

Php

 if (isset($_POST['dataTime'])) { $dataTime = $_POST['dataTime']; return json_encode(['type'=> 'success', 'mess' => 'Ok']); } else { return json_encode(['type'=> 'error', 'mess' => 'Not found']); }