Why springmvc return some kind of String will cause ajax error!
when controller return Integer like 123 ,It works fine;
when controller return Integer string like "123",It works fine;
when controller return String like "abc", the ajax will error!
The problem just like https://www.mkyong.com/jquery/jquery-ajax-request-return-200-ok-but-error-event-is-fired/
It is just simple ajax request to springmvc controller
ajax request
$.ajax({
type: "POST",
url: "/test",
data: JSON.stringify(json),
dataType: "json",
async : false,
contentType: "application/json",
success: function(msg){
alert(msg);
debugger;
result = msg;
},
error: function(msg){
debugger;
alert(msg);
}
})
controller file:
@RequestMapping("test")
public String test(){
//return "123"; ajax works fine
return 123; ajax works fine
return "abc"; //ajax parsererror
}
I expect all kind of String will be fine including String like "abc" !
Can anyone help me !
Thanks!