I am looking to update a table with data from a JavaScript function. The table is located in the same .jsp file but not inside the script.
Using AJAX
<script type="text/javascript">
function searchDetails() {
$.ajax({
type : "post",
data : {
'accountNo' : $(accNumber).val()
},
url : "/banking-internet/account-history/add",
cache : false,
success : function(data) {
var transactionList = data;
},
error : function(e) {
alert('Error: ' + e);
}
});
}
</script>
Table Structure
<tr>
<th>Transaction Type</th>
<th>Amount</th>
<th class="hide-on-mobile">Description</th>
</tr>
<c:forEach var="transaction" items="${transactionList}">
<tr>
<td>${transaction.transactionDate}</td>
<td>${transaction.transactionType}</td>
<td>${transaction.accountNarration}</td>
</tr>
</c:forEach>
The values are being passed correctly to the data. However, I am facing issues accessing the value outside of the script for further use.
success : function(data) {
var transactionList = data;
},
This segment successfully retrieves the value from the controller.
Seeking assistance, please.