Can not bind value in html table RRS feed

  • Question

  • User631634524 posted

    Hi all,

    I am creating a single page application using knockout and asp.net webmethod.

    When in js class, i make an ajax call to webmethod i can not get the value in htmt table.

    here is my js code for ajax call to web method

    Sammy(function () {
            this.get('#:days', function () {
                    type: "POST",
                    url: 'SinglePageApp.aspx/GetGoals',
                    data: "{goalDate:'" + this.params.days + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (msg) {
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
            this.get('', function () { this.app.runRoute('get', "#"+new Date()) });

    And here is my html code

    <table class="goals" data-bind="with: choosenDateGoal">
                <tbody data-bind="foreach: GetGoals">
                        <td data-bind="text: status"></td>
                        <td data-bind="text: goals"></td>
                        <td data-bind="text: notes"></td>

    Actually in js success, i can not bind status,goals and notes value. i have put web method name here

    <tbody data-bind="foreach: GetGoals">, sothat its not working. so what should i put here.

    Please help.

    Wednesday, October 3, 2012 2:25 AM

All replies

  • User-129899387 posted


    I'm not sure what problem you actually have, because you didn't post all relevant information.

    So I'll try to guess:

    1. You probably already have 


    which binds your knockout object (myViewModel) with your view.

    2. Your viewModel has GetGoals array whose each element has status, goals and notes values.

    All of these variables have to be observable: GetGoals as observable array and even all of these children: status, goals and notes have to be observable itself.

    3. You need change values in your viewModel using data from ajax response.

    If everything I mentioned is already set up, then try to describe your problem in detail here, or you can try to post your problem  on knockoutjs' forum

    Hope it helps.



    Sunday, November 4, 2012 5:04 PM