ajax请求总是返回error的问题

多半是因为返回值格式的问题,在后台返回的应与前台设定的值一直,不然就会进入error,会报404服务器错误,极有可能是后台返回的数据类型不对

public void exitSystem( HttpServletRequest request,
HttpServletResponse response) {
HttpSession session = request.getSession(false);//防止创建Session
if(session!=null){
//session.removeAttribute(Constants.LOGIN_USER);
session.invalidate();
}
String data = "{"success":"true","msg":"退出成功!"}";
try {
response.getWriter().print(data);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

另附http://jingyan.baidu.com/album/aa6a2c14d6d47a0d4c19c400.html?picindex=2

原文地址:https://www.cnblogs.com/snower/p/4195261.html