I have two click methods in my javascript as follows. Method 1 is hitting the controller method but after that when clicking on a button for Method 2, it is not hitting the controller. Here I dont want to use $.ajax call for submit. I tried different ways but am not sure why method 2 is not hitting the controller. Appreciate any inputs. Thanks.
Method 1:
$("#selectAll").click(function () {
var familyDetailsForm = $("#family_details");
var enrollmentSetupId = $("#enrollmentSetupId").val();
var eId = $("#eId").val();
var url = "";
if($("#isDental").val() == "true"){
url = GlobalVars["app_url"] + "/shop/search/addAllDentalPlans?enrollmentSetupId=" +
enrollmentSetupId+"&eId="+eId;
}
else {
url = GlobalVars["app_url"] + "/shop/search/addAllHealthPlans?enrollmentSetupId=" +
enrollmentSetupId+"&eId="+eId;
}
familyDetailsForm.attr("action", url);
familyDetailsForm.submit();
});
Method 2:
$("#removeAll").click(function () {
var remove_familyDetailsForm = $("#family_details");
var remove_enrollmentSetupId = $("#enrollmentSetupId").val();
var planType = $("#planKind").val();
var url = "";
if($("#isDental").val() == "true"){
url = GlobalVars["app_url"] + "/shop/search/removeAllDentalPlans?
remove_enrollmentSetupId=" +remove_enrollmentSetupId+"&planType="+planType;
}
else {
url = GlobalVars["app_url"] + "/shop/search/removeAllHealthPlans?
remove_enrollmentSetupId=" +remove_enrollmentSetupId+"&planType="+planType;
}
remove_familyDetailsForm.attr("action", url);
remove_familyDetailsForm.submit();
});
Controller:
@RequestMapping(value = "removeAllHealthPlans", method = RequestMethod.POST)
public String removeAllHealthPlans(HttpSession session, HttpServletRequest request, Model model)
throws Exception {
First check if your method is properly mapped. It should be rather
@RequestMapping(value = "/removeAllHealthPlans", ...)
This is of course assuming that your controller is mapped as /shop/search
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.