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.
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();
-
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**** }