I have web application where I’m trying to populate my html table using knockout.js but my table is still empty. My data is being called via ajax. jQuery and Knockout.js were all referenced to my page. Here’s the code;
HTML
<table id="payment_schedule">
<thead>
<tr class="tableHeader">
<th width="50px">
Index
</th>
<th width="50px">
Due Date
</th>
</tr>
</thead>
<tbody>
<tr data-bind="foreach: paymentSchedules">
<td data-bind="text: Index"></td>
<td data-bind="text: Month"></td>
</tr>
</tbody>
</table>
JavaScript functions
function GetComputation() {
$.ajax({
url: '/UnitSearch/CalculateMortgage',
cache: false,
dataType: 'json',
success: function (data) {
viewModel.paymentSchedules(data.PaymentSchedules);
}
});
}
var data = [];
var viewModel = {
paymentSchedules: ko.observableArray(data)
};
ko.applyBindings(viewModel);
data returned from ajax

Your code should work fine. You haven’t shown where you are calling the
GetComputationfunction but here’s a full working example.Controllers:
Index view (
~/Views/Home/Index.cshtml):In this example I am calling the
GetComputationimmediately but you could adapt the code and invoke it whenever you want. Also notice that I have applied thedata-bind="foreach: paymentSchedules"on the<tbody>and not the<tr>element.