后台返回json结果的逻辑是MapresultMap=newHashMap();resultMap.put("userType",userType);resultMap.put("phone",phone);resultMap.put("channel",channel);JSONObjectobj=newJSONObject();obj.put("code","2000");obj.put("message","成功");obj.put("result",resultMap);returnobj.toJSONString();前台得到:{"code":"2000","message":"成功","result":{"phone":"15365166305","channel":"null","userType":"高级版用户"}}可是在ajax里出现解析错误,怎么办?success:function(data){if(data.code=='2000'){userType=data.result.userType;}},error:function(request,textStatus,errorThrown){console.log(request.status);console.log(request.readyState);}errorThrown说是:Unexpectedtoken
2 回答
![?](http://img1.sycdn.imooc.com/533e4c9c0001975102200220-100-100.jpg)
千万里不及你
TA贡献1784条经验 获得超9个赞
先确认一下content-type吧,response的content-type是json么?看报错不太像,很像是返回了text/html的header
添加回答
举报
0/150
提交
取消