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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:31:39+00:00 2026-06-12T15:31:39+00:00

I have loop that for each item that call a async request to server,

  • 0

I have loop that for each item that call a async request to server, create a view with a webview for later add in a scrollview after calc the positions. In the callback, I get the server data and give to webview.

When the load method takes a little longer to perform (In a slow connection, for example), the webview is not rendered.

This happens many times in the device, but few times in the simulator. But, to simulate easily, just put a breakpoint in the load method, delaying the execution.
I suspect that there is a problem when rendering an already added webview.

I simplified the code in a one block for better understanding:

function createView(){

    var view = Ti.UI.createView({
        //...
    });

    var webview = Ti.UI.createWebView({});
    view.add(webview);

    //Callback to process webview content after receive the server data     
    view.load = function(serverData){
        webview.setUrl(serverData.url);
        webview.addEventListener('beforeload', function(){
            webview.evalJS("var value="+serverData.value+";");
        });
    };

    return view;
};

var views = new Array();

for(i=0;i < data.length;i++){

     views[i] = createView();

     //Async request to server
     var req = Ti.Network.createHTTPClient();

     req.onload = function(){
          result = JSON.parse(this.responseText);
          views[i].load(result);
     }

     req.open("POST", "http://myserver.com.br/myservice");
     req.send({myParam: data[i].value}); 
}

var scrollView = Ti.UI.createScrollView({
    //...
});

for(i=0;i < views.length;i++){

    //Calc the positions, not relevant
    views[i].width = calculedValue; 
    views[i].height = calculedValue; 

    scrollView.add(views[i]);   
}

win.add(scrollView);

Im using Titanium SDK 1.8.2 and running on iPad 2 with iOS 5.0.1.

  • 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-12T15:31:40+00:00Added an answer on June 12, 2026 at 3:31 pm

    I solved the problem evaluating the javascript data on the callback instead of on event listener

    view.load = function(serverData){
        webview.setUrl(serverData.url);
        //Not on event 'beforeload'
        //webview.addEventListener('beforeload', function(){ not on 
            webview.evalJS("var value="+serverData.value+";");
        //});
    };
    

    I think that this is related with the UI thread is not called sometimes on event listener

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

Sidebar

Related Questions

I have a loop that enters each non-empty text field into a database: foreach
I have a loop that can look like this: For Each article In artAll
I have a For Each loop that is looping through an array of strings
I have some code that runs a model in a loop. Each iteration of
I have some javascript on a view that makes an ajax call to my
I have repeated-measures data. I need to create a loop that will incrementally count
I have a state machine that needs to call a different method on each
I have a loop that finds duplicate lines in a .ini file. I can
I have a loop that runs through a variety of websites and I'd like
I have a loop that runs for approx. 25 minutes i.e 1500 seconds. [100

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.