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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:55:55+00:00 2026-05-20T09:55:55+00:00

I have a code that works great on iPhone, but when it comes to

  • 0

I have a code that works great on iPhone, but when it comes to make it run on Android, it ignores some parts.
The problem is that I have nested createHTTPClient calls:

var xhr1 = Titanium.Network.createHTTPClient();
xhr1.open('GET',url1);
xhr1.send();
xhr1.onload = function(e) {
  var list1 = JSON.parse(this.responseText); 
  var list1Length = list1.length;
  Titanium.API.info('list1 length : ' + list1Length);
  var fctForList2 = function(argument){
    var xhr2 = Titanium.Network.createHTTPClient();
    xhr2.open('GET',url1);
    xhr2.send();
    xhr2.onload = function(e) {
      // display list where a value corresponds to the argument
      var list2 = JSON.parse(this.responseText);
      var list2Length = list2.length;
      Titanium.API.info('list2 length : ' + list2Length);
    };
  };

  var argument = list1[0].someValue;
  fctForList2(argument);
};

So in the code above, I found a workaround that runs great on iPhone.
As you know, the synchronous mode can’t be forced (even if the documentation mentions that it can be done) so I have used this method to call the second xhr synchronously.

But why the list2Length is null with Android?

PS: I work under OSX with the Titanium SDK 1.6. For my tests on Android, I use the emulator (API 2.2) and a device (2.1update1).

Thanks,

Regards.

  • 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-05-20T09:55:56+00:00Added an answer on May 20, 2026 at 9:55 am

    i would do it like that:

    var xhr1 = Titanium.Network.createHTTPClient();
    var xhr2 = Titanium.Network.createHTTPClient();
    
    xhr2.onload = function(e) {
          // display list where a value corresponds to the argument
          var list2 = JSON.parse(this.responseText);
          var list2Length = list2.length;
          Titanium.API.info('list2 length : ' + list2Length);
    };
    
    xhr1.onload = function(e) {
         var list1 = JSON.parse(this.responseText); 
         var list1Length = list1.length;
         Titanium.API.info('list1 length : ' + list1Length);
    
         //second request
         xhr2.open('GET',url1);
         xhr2.send();
    };
    
    xhr1.open('GET',url1);
    xhr1.send();
    

    for what is the “argument”?

    you need to declare the onload function before calling the .open and .send method.

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

Sidebar

Related Questions

I have some Python code that works correctly when I use python.exe to run
I am querying information from Active Directory . I have code that works, but
I have a java script code that works fine when run through a browser,
I have a script that works great, but I need the background color to
I have a block of code that works and I wanted to ask what
I have code that looks like the following, which works fine for displaying the
I have a website that is perfectely centered aligned. The CSS code works fine.
I have to work on some code that's using generic lists to store a
I have some trivial code that looks like this: SortedDictionary<String, long> d = new
I have a LoginControl that works great, however, I want it to store more

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.