This is a snippet of my JavaScript code:
<script type="text/javascript">
function callMe() {
var districtId = $("#district").val();
alert(districtId);
$.ajax({
type: "POST",
url: "addBranch",
data: "districtId=" + districtId,
success: function(response) {
}
});
}
</script>
Here is a portion of my controller code:
@RequestMapping(value = "/addBranch", method = RequestMethod.POST)
public @ResponseBody
List getForm1(@ModelAttribute Branch branch, Model model,@RequestParam("districtId")
int districtId) {
try {
districtVillageList = villageService.getDistrictVillageList(districtId);
} catch (Exception er) {
log.error("error in addLoanType=" + er);
}
return districtVillageList;
}
Although I am successfully getting the list in the controller, I am unsure how to retrieve and utilize the values in my JSP file using Ajax. As I am new to working with Ajax, I would greatly appreciate any help on this matter. Thank you!