【发布时间】:2018-05-30 06:46:15
【问题描述】:
(.js)
$.ajax({
type: "POST",
//contentType : "application/json",
dataType : "json",
url: "getStateNames",
//url:"http://localhost:8081/Mining_22_11_17/pages/admin/a.jsp",
cache: false,
data: "region=" + re + "& stId=" + state_id,
success: function(response){
//$('#result').html("");
alert("hiiii state list");
var obj = JSON.parse(response);
alert("state list" + obj);
//$('#result').html("First Name:- " + obj.firstName +"</br>Last Name:- " + obj.lastName + "</br>Email:- " + obj.email);
},
error: function(){
alert('Error while request..');
}
});
Spring MVC 控制器
@RequestMapping(value="/getStateNames",method = RequestMethod.POST)
public @ResponseBody RegionDistrict add(HttpServletRequest request, HttpServletResponse response,@RequestParam String region, @RequestParam String stId) {
System.out.println("Get state");
}
【问题讨论】:
-
重新声明 state_id 在脚本中
标签: ajax spring post model-view-controller controller