Titanium Community Questions & Answer Archive

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

Oncomplete in createHttpClient

How to know that an HttpClient has completed sending the data.
I tried this but not working..
var xhr = Titanium.Network.createHTTPClient();
xhr.oncomplete = function(){
alert('Completed');
};
Can anyone help please.

— asked December 6th 2010 by Jacob John
  • iphone
0 Comments

2 Answers

  • there is no oncomplete in the httpClient documentation see here

    you want your code to look like this

    var xhr = Ti.Network.createHTTPClient();
    
    xhr.onload = function(e) {
        alert('Completed');
        Ti.API.log(xhr);
    };
    xhr.onerror = function(e) {
        throw e.error;
    };
    
    xhr.onreadystatechange = function(aEvt) {
        Ti.API.log("readyState " + xhr.readyState + " status: "
                + xhr.status);
    };
    
    xhr.open('GET', 'http://www.someurl.com' );
    
    xhr.send();
    
    — answered December 6th 2010 by Aaron Saunders
    permalink
    0 Comments
  • This code works for me just fine even though I don't believe there is any documentation on doing it this way….

    xhr.onComplete = function(e){
    ****Code Here****
    }
    
    — answered May 16th 2011 by CLINT RANKIN
    permalink
    0 Comments
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.