1 Answer
Gsanmartin
Punditsdkoslkdosdkoskdo
Is there anyway to submit Form with AJAX passing form data to PHP without page refresh?
Can anyone tell me why this bit of code isn't working?
<html>
<head>
[removed] src="http://code.jquery.com/jquery-1.9.1.js">[removed]
[removed]
$(function () {
$('form').bind('submit', function () {
$.ajax({
type: 'post',
url: 'post.php',
data: $('form').serialize(),
success: function () {
alert('form was submitted');
}
});
return false;
});
});
[removed]
</head>
<body>
<form>
<input name="time" value="00:00:00.00">
<input name="date" value="0000-00-00">
<input name="submit" type="button" value="Submit">
</form>
</body>
</html>
When I push submit nothing happens. In the receiving php file I'm using $_POST['time'] and $_POST['date'] to put the data in a mysql query but it's just not getting the data. Any suggestions? I'm assuming it's something to do with the submit button but I can't figure it out