js代码:
success: function (response) {
alert(response);}
controller代码:
@RequestMapping("/checklogin")
@ResponseBody
public String checkLogin() {
return "error";
}
js接受的字符是"error",而不是error,多了双引号
如图

阅读下json规范 http://www.json.org/json-zh.html
单字符串是由双引号包围的任意数量Unicode字符的集合
感谢解答~
你可以debug看一下js的XHR对象,
返回里不仅有responseText,还有responseJSON
后面一个应该不会返回双引号
Most helpful comment
阅读下json规范 http://www.json.org/json-zh.html
单字符串是由双引号包围的任意数量Unicode字符的集合