I want to make a form where you write a number send it with Jquery and is shown by PHP without refreshing the page ,by far i have this code but if preventDefault() is placed it will post but the content is not shown,also if i remove it, the content is shown but the page will pe refreshed.
Javascript:
$('#testut').unbind('submit').bind('submit',function(ev) {
ev.preventDefault();
$.ajax({
type: 'post',
url: 'incerc.php',
data: $('form').serialize(),
success: function () {
$('.success').fadeIn(500);
}
});
});
}
HTML:
Test
<br />
<?php
if(isset($_POST['test'])) {
$test = $_POST['test'];
$numar = $_POST['numar'];
echo 'Order name:'.$test.'<br />Number:'.$numar.'<br />';
} else {
echo 'No <br />';
}
?>
<div id='testut'>
<form id='test' method='post'>
<input type='text' name='numar'><br />
<input type='submit' name='test' onclick ='check()' value='Place'><br />
<span class='success' style='display:none'>Order was successfully placed.</span>
</form>
</div>