<form id="jobsform">
<input type="text" name="job_name">
<textarea name="job_description"></textarea>
<input type="submit" name="submit">
</form>
Скрпит:
<script>
$(document).ready(function() {
$('#jobsform').submit(function(event) {
event.preventDefault();
$.ajax({
type: 'POST',
url: 'include/job.php',
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success: function(result) {
alert("Zbs");
},
});
});
});
</script>
обработчик:
<?php
require_once 'database.php';
if (isset($_POST['submit'])) {
$job_name = $_POST['job_name'];
$job_description = $_POST['job_description'];
global $link;
$insert_query = "INSERT INTO jobs (`position`, `description`) VALUES ('$job_name', '$job_description')";
$result = mysqli_query($link, $insert_query);
}
?>
без AJAX, то есть
<form id="jobsform" method="POST" action="include/job.php">
все прекрасно работает