0
我使用ajax将表单发布到我的localproxy,然后发布到附属客户端和我的数据库。然而,它不会使用ajax发布或提出错误。我在其他网站上使用这种确切的代码格式没有问题。Ajax Post疑难解答
我的Ajax代码
$(document).ready(function(){
// ajax code start
$('#form').on('submit', function (e){
e.preventDefault();
$.ajax({
type: "POST",
url: "/localProxy.php",
data: $('#form').serialize(),
success: function (response) {
document.location = '/thank-you';
// do something!
},
error: function() {
alert('There was a problem!'); // handle error
}
});
});
这里是我目前的形式,标题和提交代码
<form id="form" name="form" >
<input type="submit" name="submit" id="submit" value="Enter" />
无论是默认提交激活绕过AJAX或警报消息出现。
awesome,修复了这个问题,谢谢 – user1684086