Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Wait for the function to execute..

Hi guys!

This question is more syntax oriented I think. I have a problem with a function wait.

I have a return that return object in one file:

function get_rss_data(url)
  return data;

I use Include to include it to app.js.

in app.js I call it with:

var results = get_rss_data('http:...');
Ti.API.info("results: "+result.length);

When i run the app application does not wait for the get_rss_data to finish and that is why the Ti.API.info is null. How can I write the code in app.js to wait for the get_rss_data to finish? Thanks!

Kind regards, Miha

— asked May 10th 2010 by Miha Jakovac
  • android
  • function

1 Answer

  • Accepted Answer

    if you use a xhr inside your get_rss_data, this is done asynchronous, so you need to create a function triggered at onComplete event for the xhr that will use the data now available.

    — answered May 10th 2010 by Dan Tamas
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.