日期:2014-05-16  浏览次数:20659 次

spring3 mvc 返回的json格式数据jquery解析不了
用ajax提交的请求返回的json数据data:

---------------------------
来自网页的消息
---------------------------
{"description":null,"result":{"address":null,"id":10,"email":"chris.zhang@foxmail.com","pwd":"1","loginName":"啊啊","nickName":"111搜索","headPicPath":null,"mobilePhone":"2","deskPhone":null,"vid":null,"birthday":null,"sex":null,"lastName":null,"firstName":null,"cityId":0,"districtId":0,"lasLoginIp":null,"creatTime":1367482926000,"userType":null,"userStatus":null,"lasLogiClient":null,"lasLogiTime":1367481551000},"isSuccessMessage":1,"statusCode":220000,"sendDetail":null}
---------------------------
确定   
---------------------------

可以直接alert出来,以上是alert(data)的结果
可是为什么alert(data.result)就是undefined了?
JSON jQuery Spring

------解决方案--------------------
---------------------------//去掉
来自网页的消息//去掉
---------------------------/去掉
{"description":null,"result":{"address":null,"id":10,"email":"chris.zhang@foxmail.com","pwd":"1","loginName":"啊啊","nickName":"111搜索","headPicPath":null,"mobilePhone":"2","deskPhone":null,"vid":null,"birthday":null,"sex":null,"lastName":null,"firstName":null,"cityId":0,"districtId":0,"lasLoginIp":null,"creatTime":1367482926000,"userType":null,"userStatus":null,"lasLogiClient":null,"lasLogiTime":1367481551000},"isSuccessMessage":1,"statusCode":220000,"sendDetail":null}
---------------------------//去掉
确定   //去掉
---------------------------//去掉



你这压根就不是JSON字符串。把上面标注的全部去掉。
------解决方案--------------------
加上dataType:'json',jquery应该按照文本来处理了,没有处理成json对象