ok guys, I was able to solve it now!..
I just need to provide a value in my request mapping
Code:
// when get account detail is clicked it will call this method
@RequestMapping(value = "/detail",method=RequestMethod.POST)
public @ResponseBody String getAccountDetails(@RequestParam(value="accountid") String accountid){
return somefunct.getAccountDetails(accountid);
}
// when get account summary is clicked it will call this method
@RequestMapping(value = "/summary", method=RequestMethod.POST)
public @ResponseBody String getAccountSummary(@RequestParam(value="accountid") String accountid){
return somefunct.getAccountSummary(accountid);
}
/* when submit button is clicked... Form is submitted for saving*/
@RequestMapping(method=RequestMethod.POST)
public String submitForm(){
// save here
return "myform";
};
then, the ajax code for each button is
Code:
// button detail is clicked
$("#btndetail").click(function() {
var accountid= $("#accountid").val();
$.ajax({
type : "POST",
url : "/mypage/detail",
data : "accountid=" + accountid,
success : function(response) {// we have the response
alert(response); },
error : function(e) {
alert('Error: ' + e);
}
});
});
// button summary is clicked
$("#btnsummary").click(function() {
var accountid= $("#accountid").val();
$.ajax({
type : "POST",
url : "/mypage/summary",
data : "accountid=" + accountid,
success : function(response) {// we have the response
alert(response); },
error : function(e) {
alert('Error: ' + e);
}
});
});