日期:2014-05-16  浏览次数:20706 次

jquery ajax 回调函数失败?
ajax代码:
$.ajax({

url:"userLogin.do",
data: $loginWindowForm.serialize(),
type: "POST",
dataType: "json",
cache: false,
beforeSend: function() {
$loginWindowForm.find("button").attr("disabled", true);
},
success: function(data) {
alert("Data Loaded: ");
if (data.status == "success") {
$.flushHeaderInfo();
$.closeDialog("loginWindow");
}
$.message({type: data.status, content: data.message});
if(redirectUrl != null) {
location.href = redirectUrl;
}
},error:function(data){alert("出错");},
complete: function() {
$loginWindowForm.find("button").attr("disabled", false);
$loginWindowCaptcha.val("");
loginWindowCaptchaImageRefresh();
}
});
servelt代码:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String username = request.getParameter("member.username");
String password = request.getParameter("member.password");
PrintWriter out = response.getWriter();
if(username.equals("admin")&&password.equals("123456")) out.print("登录成功");
else out.print("用户名或者密码错误");
System.out.println("usename "+username+" "+password);
}
问题:能获取username和password,但是ajax总是弹出“错误”,不执行success:。。。?求解决方法!

------解决方案--------------------
firebug调试下ajax请求成功吗
单独运行下接收页,看有错误没