Titanium Community Questions & Answer Archive

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

httpclient settimeout and onerror don't work in android?

I'm using Android and cannot get either settimeout or onerror to work with the httpclient object. Here is the code:

function ajaxCall(method, callbackFunction) {
    var loader = Ti.Network.createHTTPClient();
    loader.setTimeout(30000);
    loader.onload = callbackFunction;
    loader.onerror = ajaxError;
    loader.open("GET", url + method);
    loader.send();
}

I've tried setTimeout with and without the braces and it does nothing either way, it never triggers the onerror function, even if I disconnect my internet. What am I missing? Is this one more Android bug to add to the list of a hundred I've already found in my first week of Appcelerator development?

— asked November 6th 2010 by Justin Toth
  • httpclient
  • settimeout
0 Comments

1 Answer

  • I saw this on an old posting

        loader.setTimeout([30000]);
    
    — answered November 7th 2010 by Aaron Saunders
    permalink
    1 Comment
    • Thanks for the response, but I saw that post and like I said, "I've tried setTimeout with and without the braces and it does nothing either way". Basically I'm just trying to make sure that I can handle errors in my ajax calls gracefully, as if the internet connection drops out for a moment on the phone it shouldn't crash the app.

      — commented November 7th 2010 by Justin Toth
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.