发送ajax请求到后台(Java),debug后台数据没有问题,甚至自己写的结果
PrintWriter out;
try {
out=response.getWriter();
out.write("{'id':12,'name':'ok' }");
} catch (IOException e) {
e.printStackTrace();
}
但是返回结果进error方法
error:function(xhr,status,error){
throw new Error("status:"+status+"; Error:"+error);
}
具体结果:
Uncaught Error: status:parsererror; Error:SyntaxError: Unexpected token <
求教问题出在哪里?
注意服务器写出响应的编码
注意服务器写响应的content-type
注意ajax解析的数据类型