How to pass email id via ajax call (not as string), i need to catch that email parameter in spring controller.
$.ajax({
type : "POST",
contentType : "application/json",
data: data,
dataType: "text",
url : "<%=request.getContextPath()%>/methodName";,
success : function(data){
}
});
Java code:
@RequestMapping(value="/methodName/{email}", method =RequestMethod.POST,produces="application/json")
@ResponseBody
public String resetPassword(@PathVariable(value = "email") String email) throws Exception{
//do something
return "success";
}
The below code did the trick.
$.ajax({
type : "POST",
data: {
'email': email
},
url : "<%=request.getContextPath()%>/methodName";,
success : function(data){
}
});
@RequestMapping(value="/methodName", method =RequestMethod.POST)
@ResponseBody
public String resetPassword(@RequestParam(value = "email") String email) throws Exception{
//do something
return "success";
}