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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:48:55+00:00 2026-06-04T19:48:55+00:00

I need to call multiple web services to get different bits of information about

  • 0

I need to call multiple web services to get different bits of information about a resource. For instance I may have the following calls for a multi-tenant app:

  1. GET locations
  2. GET locations/{id}/servers
  3. GET locations/{id}/tenants
  4. etc.

With each of these calls I end up with a different jQuery ajax call to a corresponding web service. However my UI displays a summary page of sorts that displays a table for the results from each query. It seems it would be really easy to build a single Knockout ViewModel that then has ObservableArrays for each query result but maybe I’m approaching this incorrectly. Either way I’m not sure how to consolidate the multiple calls to one model or utilize multiple models for each call.

Does anyone have any documentation or sample code they could share to point me in the right direction?

Update: I want to acheive this end result/structure in my Knockout object. Essentially it is a one to many relationship, one location to many servers or tenants.

LOCATION
  - Name
  - ID
  - Date
  - Servers []
  - Tenants []

Thanks

  • 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-04T19:48:57+00:00Added an answer on June 4, 2026 at 7:48 pm

    What I do is create one view model for the page and update the properties with the values from each call. I use the ko.mapping plugin with three parameters to update the existing observable array and make the properties observable. The ko.mapping.fromJSON calls will go in the success function of your AJAX call where you get the results, I just made them click handlers for simplicity.
    http://jsfiddle.net/jgoemat/v9XTf/

    var jsonLocations = '[{"name":"home"},{"name":"work"}]';
    var jsonServers = '[{"name":"Mercury"},{"name":"Venus"}]';
    var jsonTenants = '[{"name":"Betty"},{"name":"Frank"}]';
    
    function ViewModel() {
        var self = this;
        self.locations = ko.observableArray();
        self.servers = ko.observableArray();
        self.tenants = ko.observableArray();
    
        self.loadLocations = function() { ko.mapping.fromJSON(jsonLocations, {}, self.locations); };
        self.loadServers  = function() { ko.mapping.fromJSON(jsonServers, {}, self.servers); };
        self.loadTenants = function() { ko.mapping.fromJSON(jsonTenants, {}, self.tenants); };
    }
    
    var my = { vm: new ViewModel() };                                                        
    
    ko.applyBindings(my.vm);​
    

    edit – Updated Fiddle

    If the locations contain the tenants, you can modify that property on the location, the ko event handler passes the current model to the handler:

    self.loadServers  = function(location) {
        ko.mapping.fromJSON(jsonServers, {}, location.Servers);
    };
    

    If you’re binding with jQuery, you can use ko.dataFor(element) to get the model from the context where the element is:

    $('.loadAll').live('click', function(e) {
        var location = ko.dataFor(this);
        // location can be used in success callback of ajax 
        ko.mapping.fromJSON(jsonServers, {}, location.Servers);
        ko.mapping.fromJSON(jsonTenants, {}, location.Tenants);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple projects that need to pass user login information to common-api project
I have to scrap a web site where i need to fetch multiple URLs
I have this code where I need to call a function multiple times. $(window).resize(function()
I have a method that I call to make web service requests using GET.
I need to create a project for multiple web services using WCF in c#.
We need to call a web service, described in a wsdl and multiple technical
I need to call a number of different procedures within an Oracle package successively
I need to call my WCF REST Service with multiple parameters with the POST
I need to make multiple NSURLConnections to a JSON Web Service. I would like
I have an ASP.Net web application that is deployed to a number of different

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.