im a beginner coder and i want to make a contact form sending a json object to another php file. This is my current code
[...]
<body>
<form id="form" class="formular">
<div class="input-group">
<input id="phone" type="tel" class="form-control" name="phone" placeholder="phone" required>
</div>
<br>
<div class="input-group">
<input type="email" id="email" class="form-control" name="email" placeholder="mail" required>
</div>
<br>
<div class="input-group">
<textarea id="message" class="form-control" placeholder="message..." required></textarea>
</div>
<button id="form_submit_button" name="form_submit_button">Send!</button>
</form>
</body>
</html>
<?php
?>
<script>
jQuery(document).ready(function($) {
$("#form_submit_button").click(function (event) {
event.preventDefault();
$.ajax({
type: 'POST',
url: 'test.php',
data: JSON.stringify({ Form: $('#form').val }),
contentType: "application/json; charset=utf-8",
dataType: "json",
})
});
});
</script>
The test.php simly is: var_dump($_POST); Of course it's always 0. Can someone help me please :)