[size=medium]后台用servlet拼接出json字符串,前台用ajax接收,datatype设为text/html能顺利取到字符串,但是datatype改为json后ajax响应错误
[color=brown]String json="{";
json+="'userName':'tiny',";
json+="'userNo':'123'}";
writer.write(json);[/color]
后将输出字符串改为
[color=brown]String json="{";
json+="\"userName\":\"tiny\",";
json+="\"userNo\":\"123\"}";
writer.write(json);[/color]
则成功[/size]
[color=brown]String json="{";
json+="'userName':'tiny',";
json+="'userNo':'123'}";
writer.write(json);[/color]
后将输出字符串改为
[color=brown]String json="{";
json+="\"userName\":\"tiny\",";
json+="\"userNo\":\"123\"}";
writer.write(json);[/color]
则成功[/size]