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