0
我正在使用Spring 3和JQuery。如何从JSON读取地图数据
我想返回地图从我的春节控制器
{由elementID,它的价值}并利用这些数据来更新视图。
控制器代码
@RequestMapping(value="/hpcCalResult")
public ResponseEntity<Map<String, String>> calculateHeathPlanCost(HttpServletRequest request) {
Map<String,String> requestMap = getMapFromRequest(request);
boolean isError = false;
Map<String,String> responseMap = new HashMap<String, String>();
try{
responseMap = this.healthPlanService.getResponseMapAfterHPCostCalc(requestMap);
}catch(HCException e){
isError = true;
responseMap.put("error", Springi18nUtils.getMessage(e.getMessageCode().getName(), null));
}
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
if(isError){
return new ResponseEntity<Map<String, String>>(responseMap, headers, HttpStatus.INTERNAL_SERVER_ERROR);
}else
return new ResponseEntity<Map<String, String>>(responseMap, headers, HttpStatus.OK);
}
现在我想使用JSP文件Ajax请求此响应地图UI更新。
我jQuery代码是代码:
$("#Continue").click(function() {
var form = $("#calculator");
var data = form.serialize();
$.post(form.attr("action"), data ,
function(data) {
<<< dont know how to read the data as so that i can get key values which i will use to update the form fields . >>>
});
}
);
});
请帮我出过一样。 谢谢。
谢谢你的回复。它与数据一起工作。 <>。 –
2011-12-26 13:39:18
所以这个答案对你有帮助吗? :) – OhadR 2011-12-26 14:02:19