the logic for the background to return the json result is
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("userType", userType);
resultMap.put("phone", phone);
resultMap.put("channel", channel);
JSONObject obj = new JSONObject();
obj.put("code", "2000");
obj.put("message", "");
obj.put("result", resultMap);
return obj.toJSONString();
get it at the front desk:
{"code":"2000","message":"","result":{"phone":"15365166305","channel":"null","userType":""}}
but what if there is a parsing error in 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 says yes:
Unexpected token < in JSON at position 0"