Controller:
@RequestMapping(value = "/checkEnrollmentStatus", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> checkEnrollmentStatus(接受的参数)
{
Map<String, String> deviceInfoMap = new HashMap<String, String>();
//把你要的数据放进去,key 和 value,直接返回map,主要@ResponseBody,直接返回的是json
return deviceInfoMap;
}
ajax:
$.ajax({
url: url,
type: 'POST',
timeout: 15*1000,
success: function(result) {
// result 就是返回的值,直接是JSON对象了
alert(result.key1) ;
alert(result.key2) ;
alert(result.key3) ;
},
error:function(result){
}
});//end
} ;