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 8347285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:19:04+00:00 2026-06-09T07:19:04+00:00

$.ajax({ url: /survey/surveyQuestions, success: function (questionsData) { $.ajax({ url: /survey/surveyOptions, success: function (optionsData) {

  • 0
     $.ajax({
                    url: "/survey/surveyQuestions",
                    success: function (questionsData) {
                        $.ajax({
                            url: "/survey/surveyOptions",
                            success: function (optionsData) {
                                alert(questionsData.length);
                                for (var i = 0; i < questionsData.length; i++) {
                                    QuestionsScript.Question = ko.mapping.fromJS(questionsData[i]); 
                                    ko.applyBindings(QuestionsScript, document.getElementById("innerDiv")); 
                                    for (var j = 0; j < optionsData.length; j++) { 
                                               if (optionsData[j].QuestionId = questionsData.QuestionId[i]) {
                                                     OptionsScript.Option = ko.mapping.fromJS(optionsData[j]);
                                                     ko.applyBindings(OptionsScript, document.getElementById(" ... here i nee to give options template table Id....."));
                                                  }
                                        }
                                }


                            }
                        });

                    }
                });

I need to bind like below

Question 1
       Option1
       Option2
       Option3
Question 2
       Option1
       Option2
       Option3
Question 3
        Option2
        Option3

My Templates are

<script id="QuestionsScript" type="text/x-jquery-tmpl">
<div data-bind="attr:{id :QuestionId}"  class="question">
    <h2><label data-bind="text :QuestionText" /></h2>
    <div class="option">
        <table data-bind="attr:{id : QuestionId} , template: {name:'OptionsScript', foreach: Option}">
            <tbody>
            </tbody>
        </table>
    </div>
</div>
</script>
<script id="OptionsScript" type="text/x-jquery-tmpl">
<tr>
    <td>{{= OptionText}}</td>
</tr>
</script>

As I have stated about my desired output and template,I am not aware why I can’t get that.
so Kindly provide me with any sample code for this.
Thanks in advance.

  • 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-09T07:19:06+00:00Added an answer on June 9, 2026 at 7:19 am

    I think you can do this like that:

    function Question(id, name) {
        this.id = id;
        this.name = name;
        this.answers = ko.observableArray();
    }
    
    function Answer(id, name) {
        this.id = id;
        this.name = name;
    }
    
    function ViewModel() {
        this.questions = ko.observableArray();
        var self = this;
    
        //dummy data
        self.init = function () {
            var q1 = new Question(1, "Question 1");
            var q1a1 = new Answer(1, "Option 1");
            var q1a2 = new Answer(2, "Option 2");
            q1.answers([q1a1, q1a2]);
    
            var q2 = new Question(2, "Question 2");
            var q2a1 = new Answer(1, "Option 1");
            var q2a2 = new Answer(2, "Option 2");
            var q2a3 = new Answer(3, "Option 3");
            q2.answers([q2a1, q2a2, q2a3]);
    
            var q3 = new Question(3, "Question 3");
            var q3a1 = new Answer(1, "Option 1");
            var q3a2 = new Answer(2, "Option 2");
            var q3a3 = new Answer(3, "Option 3");
            q3.answers([q3a1, q3a2, q3a3]);
    
            self.questions([q1, q2, q3]);
        };
    
        self.init();
    }
    

    And bind view model like that:

    <div data-bind="foreach:questions">
        <div data-bind="attr:{id :id}" class="question">
            <h2><label data-bind="text :name" /></h2>
            <div class="option">
                <table data-bind="attr:{id : id}">
                    <tbody data-bind="foreach:answers">
                        <tr>
                            <td data-bind="text:name"></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    

    Here is fiddle with example.

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

Sidebar

Related Questions

Here is my jquery: $.ajax({ url: hash, success: function(data){ var thePage = $(data); alert(data);
function checkSession(){ $.ajax({url: session.php, success: function(data){ if( data == 1){ var postFilen = 'msg.php';
Could someone tell me if this: $.ajax({ url: 'test.html', success: function(data) { alert(Data Loaded:
$.ajax({ url: plugin.js, dataType: 'script', cache: true, success: function() { alert('loaded'); }}); 1) I
$.ajax({ url: http://ajaxhttpheaders.appspot.com, dataType: 'jsonp', success: function(headers) { language = headers['Accept-Language']; alert(language); }, //it
$.ajax({ url: notifications.php, dataType: json, success: function(responseJSON) { if (responseJSON.length > 0) { document.title
function checkSession(){ $.ajax({url: session.php, success: function(data){ if( data == 1){ var postFilen = 'msg.php';
$(document).ready(function(){ setInterval(function(){ $.ajax({ url: getLiveData.php, success: function(result){ $.each(result, function(i, result){ var t = $(table#insideTable);
I have the ajax query var url = http://ISAServer.domain.com/WebSite; $.ajax({ url: url, success: function
The Code- $.ajax({ url: edit.php, success: function(html) { $(#last).html(html).hide().slideDown('slow'); alert(hello); } }); Mozilla shows

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.