【发布时间】:2017-05-11 12:15:00
【问题描述】:
我的表单中有一个 ajax 帖子。当它成功时,我想重定向到另一个网页..
我现在拥有的:
$.ajax({
type : 'POST',
url : '/system/login.php',
data : formData,
dataType : 'json',
success: function(data) {
if(!data.success){
if(data.errors.username){
alert(data.errors.username);
}
if(data.errors.password){
alert(data.errors.password);
}
if(data.errors.login){
alert(data.errors.login);
}
}
else{
location.href = "http://localhost/me.php"
}
},
error: function(xhr){
alert(xhr.responseText);
}
});
有人可以帮助我吗?因为我没有尝试过任何工作。
【问题讨论】:
-
在 DUP 答案中具体查看 this comment
-
会触发错误功能吗?因为 system/login.php 可能不会返回 200 OK