Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9168475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:38:03+00:00 2026-06-17T15:38:03+00:00

I have web application where I’m trying to populate my html table using knockout.js

  • 0

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

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:38:04+00:00Added an answer on June 17, 2026 at 3:38 pm

    Your code should work fine. You haven’t shown where you are calling the GetComputation function but here’s a full working example.

    Controllers:

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }
    }
    
    public class UnitSearchController : Controller
    {
        public ActionResult CalculateMortgage()
        {
            var data = new 
            {
                PaymentSchedules = new[] 
                {
                    new { Index = "Reservation Fee", Month = "23-Jan-13" },
                    new { Index = "Reservation Fee", Month = "25-Jan-13" },
                }
            };
            return Json(data, JsonRequestBehavior.AllowGet);
        }
    }
    

    Index view (~/Views/Home/Index.cshtml):

    @{
        Layout = null;
    }
    
    <!DOCTYPE html>
    
    <html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>Index</title>
    </head>
    <body>
        <table id="payment_schedule">
            <thead>
                <tr class="tableHeader">
                    <th>Index</th>
                    <th>Due Date</th>
                </tr>
            </thead>
            <tbody data-bind="foreach: paymentSchedules">
                <tr>
                    <td data-bind="text: Index"></td>
                    <td data-bind="text: Month"></td>
                </tr>
            </tbody>
        </table>
    
        <script type="text/javascript" src="@Url.Content("~/scripts/jquery-1.7.1.js")"></script>
        <script type="text/javascript" src="@Url.Content("~/scripts/knockout-2.1.0.js")"></script>
        <script type="text/javascript">
            var data = [];
            var viewModel = {
                paymentSchedules: ko.observableArray(data)
            };
            ko.applyBindings(viewModel);
    
            function GetComputation() {
                $.ajax({
                    url: '/UnitSearch/CalculateMortgage',
                    cache: false,
                    success: function (data) {
                        viewModel.paymentSchedules(data.PaymentSchedules);
                    }
                });
            }
    
            // I am calling the GetComputation function immediately in this example
            // to populate the table with data but you could call it whenever you want
            GetComputation();
        </script>
    </body>
    </html>
    

    In this example I am calling the GetComputation immediately but you could adapt the code and invoke it whenever you want. Also notice that I have applied the data-bind="foreach: paymentSchedules" on the <tbody> and not the <tr> element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have web application written in java using Eclipse. It has just one servlet
I have web application written in Java. Im using BeanUtils.copyProperties method. If a date
I have this web application that i have created using Wicket, Guice and JPA.
i have a web application built with HTML(front-end),java(server-side) and i have a textarea when
I have a Web Application that I'm trying to move from Sun Application Server
I have web application in that i am using tabbed interface control in this
I have web application deployed on websphere application server 7.0. User logins using /j_security_check.
i have Web Application which should use JSF 2.0 libraries included in WEB-INF/lib... but
I have web application which using spring wicket and sql-processor (similar to mybatis) which
I have web application in which I am using JSF + Primefaces for UI.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.