This is what I tried so far
<input id="allPlAccounts" type="hidden" th:value="${allPlAccounts}"/>
<script type="text/javascript">
$("#printList").on('click', function () {
var customers = ($("#allPlAccounts").val())
$.ajax({
type: "POST",
url: "/coopmis/waterTariff/generateReport",
data: JSON.stringify(customers),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
}
});
})
</script>
Below you can see my controller method.
@PostMapping(path = "/coopmis/waterTariff/generateReport",produces = "application/json;charset=UTF-8")
public void getCustomerByBranch(@RequestBody List<PlAccount> plAccountList) {
}
I want to send allPlAccounts arraylist to spring controller via ajax, How to do this?