Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1161] HTTPClient methods undefined on Android

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionInvalid
Resolution Date2014-05-19T05:58:09.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid, httpclient
ReporterDmitri
AssigneeRitu Agrawal
Created2014-05-13T16:33:47.000+0000
Updated2016-03-08T07:37:31.000+0000

Description

After creating a HTTPClient object on android, all methods are undefined. For example, this works fine on iOS, shows "method undefined" for Android: var httpClient = Ti.Network.createHTTPClient(); httpClient.setOnload(function(e) { // Stuff }); httpClient.setOnerror(function(e) { // More Stuff }); httpClient.open("GET", url); httpClient.send();

Comments

  1. Ritu Agrawal 2014-05-14

    You should be using onload and onerror as documented here: http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Network.HTTPClient
       var url = "http://www.appcelerator.com";
        var client = Ti.Network.createHTTPClient({
            // function called when the response data is available
            onload : function(e) {
                Ti.API.info("Received text: " + this.responseText);
                alert('success');
            },
            // function called when an error occurs, including a timeout
            onerror : function(e) {
                Ti.API.debug(e.error);
                alert('error');
            },
            timeout : 5000  // in milliseconds
        });
        // Prepare the connection.
        client.open("GET", url);
        // Send the request.
        client.send();
       

JSON Source