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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:05:03+00:00 2026-06-09T16:05:03+00:00

Hey all I’m trying to get a window populated with a table view that

  • 0

Hey all I’m trying to get a window populated with a table view that is populated from a network function in Titanium Studio, build: 2.1.1.201207271312. I have the data being fetched properlybut the problem is that the program continues to run without waiting for the table view to be populated properly. Here’s the code:

ui.js:

bs.ui.createTransitRoutesListWindow = function() {

    var winbsRoutesList = Titanium.UI.createWindow({
    });
    var tv2 = Ti.UI.createTableView();
    tv2 = bs.ui.createbsRouteListTableView();

    winbsRoutesList.add(tv2);       
};

bs.ui.createbsRouteListTableView = function() {

    var tv = Ti.UI.createTableView();       

    Ti.API.info('populating data');
        var busStopList = bs.db.routeStopList(); 

        tv.setData(busStopList);

        return tv;

};

db.js:

 bs.db.routeStopList = function() {
var stoplist = [];

bs.net.getRoutes(function(data) {
    Ti.API.info('data length: '+data.length);
    for (var i = 0;i<data.length;i++) {
        stoplist.push({
            title:data[i].stopName,
            id: i
        });
    }

});
return stoplist;
 }

network.js

bs.net.getRoutes = function(_cb) { 

    var xhr = Titanium.Network.createHTTPClient();
    xhr.onload = function() {  
        _cb(JSON.parse(this.responseText));

    Ti.API.info(this.responseText)
    };
    xhr.onerror = function(event) {
    }
    xhr.open("GET","<URL to valid JSON>", true);  
    //+ Ti.App.Properties.getString('currentBus','This is a string default')
    xhr.send();

};
  • 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-09T16:05:05+00:00Added an answer on June 9, 2026 at 4:05 pm

    bussearch.net.getRoutes() is an AJAX operation and thus it is asynchronous. This means that the code will NOT wait for it to complete. The code will proceed while the response is going. The time it will respond is not known also.

    If you want to do something after the data returns, you should do everything in the callback instead or create deferred objects like jQuery (which are basically callback containers).

    //db.js
    bussearch.db.routeStopList = function(callback) {
        var stoplist = [];
        bussearch.net.getRoutes(function(data) {
            ....
            callback.call(this,stoplist);
        });
    }
    
    //ui.js
    bussearch.ui.createBussearchRouteListTableView = function(callback) {
        var tv = Ti.UI.createTableView();       
        Ti.API.info('populating data');
        bussearch.db.routeStopList(function(busStopList){
            tv.setData(busStopList);
            callback.call(this,tv);
        }); 
    };
    
    //calling createBussearchRouteListTableView()
    createBussearchRouteListTableView(function(tv){
        //tv in here is the data
        //do inside here what you want to do to tv after it's retrieved
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, i am trying to get my bottom bar to center on the
Hey all i am trying to delete a key from the registery but i
Hey all i have an XML file that i am trying to loop though.
Hey all. Ive got a headache trying to get my head around this. I
Hey all i am trying to find some code that would allow me to
Hey all, weird question. My company has an application from another company that records
Hey all I'm trying to make a 3d game in with 2d sprite characters.
Hey all, I want to change a value in a table (in a mysql
Hey all. I'm reading from one sql-format file to another, and two bytes in
Hey all I want to reseed my IDENTITY COLUMN values starting from 1 I

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.