使用AJAX表單提交將表單數(shù)據(jù)傳遞給PHP而不刷新頁面任何人都可以告訴我為什么這段代碼不起作用?<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(function () {
$('form').bind('submit', function () {
$.ajax({
type: 'post',
url: 'post.php',
data: $('form').serialize(),
success: function () {
alert('form was submitted');
}
});
return false;
});
});
</script>
</head>
<body>
<form>
<input name="time" value="00:00:00.00"><br>
<input name="date" value="0000-00-00"><br>
<input name="submit" type="button" value="Submit">
</form>
</body></html>當(dāng)我推送提交沒有任何反應(yīng)。在接收php文件中,我使用$ _POST ['time']和$ _POST ['date']將數(shù)據(jù)放入mysql查詢中,但它只是沒有獲取數(shù)據(jù)。有什么建議?我假設(shè)它與提交按鈕有關(guān),但我無法弄明白
- 3 回答
- 0 關(guān)注
- 1001 瀏覽
添加回答
舉報(bào)
0/150
提交
取消