Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19030] Android: HttpClient setOnload() and setOnerror() methods do not work

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2015-06-25T02:26:25.000+0000
Affected Version/sRelease 3.5.1, Release 4.0.0
Fix Version/sRelease 5.0.0
ComponentsAndroid
Labelshttpclient, setOnerror, setOnload
ReporterShuo Liang
AssigneeHieu Pham
Created2015-06-16T02:24:06.000+0000
Updated2015-08-21T20:40:42.000+0000

Description

Reproduce Step:

1.Simple run the following code in a classic mobile project.
var url = "http://www.appcelerator.com";
var client = Ti.Network.createHTTPClient({
     timeout : 5000  // in milliseconds
 });
 
 client.setOnload(function(e) {
 	Ti.API.info("Received text: " + this.responseText);
        alert('success');
 });
 
 client.setOnerror(function(e) {
 	Ti.API.debug(e.error);
        alert('error');
 });
 
 // Prepare the connection.
 client.open("GET", url);
 // Send the request.
 client.send();

Expect Result:

Should fire alert event. Like its behaviour in iOS

Acutal Result:

Return a error, like this:
[ERROR] :  TiExceptionHandler: (main) [100,100] ----- Titanium Javascript Runtime Error -----
[ERROR] :  TiExceptionHandler: (main) [0,100] - In app.js:413,9
[ERROR] :  TiExceptionHandler: (main) [0,100] - Message: Uncaught TypeError: Object #<HTTPClient> has no method 'setOnload'
[ERROR] :  TiExceptionHandler: (main) [1,101] - Source:  client.setOnload(function(e) {
[ERROR] :  V8Exception: Exception occurred at app.js:413: Uncaught TypeError: Object #<HTTPClient> has no method 'setOnload'

Comments

  1. Hieu Pham 2015-06-24

    master PR: https://github.com/appcelerator/titanium_mobile/pull/6930
  2. Lokesh Choudhary 2015-08-21

    Verified the fix. The setOnload() and setOnerror() methods work as expected. Closing. Environment: Appc Studio : 4.2.0.201508062204 Ti SDK : 5.0.0.v20150821030422 Ti CLI : 4.1.5 Alloy : 1.7.5 MAC Yosemite : 10.10.4 Appc NPM : 4.2.0-1 Appc CLI : 5.0.0-12 Node: v0.10.37 Nexus 5 - Android 5.1.1 Node : v0.10.37

JSON Source