Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Synchronous http client

$
0
0

here is my code i'm calling a function

contenturlresp(id);
                        Ti.API.info(e.index);
 
function contenturlresp(id) {
    var url = Alloy.Globals.networkurl + "/lb/" + id + "/vu";
    var xhr = Ti.Network.createHTTPClient({
        // function called when the response data is available
        onload : function(e) {
            Ti.API.info("Received link details...: " + this.responseText);
            return this.responseText;
 
        },
        // function called when an error occurs, including a timeout
        onerror : function(e) {
 
            alert(e);
        },
        timeout : 5000 // in milliseconds
    });
    // Prepare the connection.
    xhr.open("GET", url, false);
    // Send the request.
 
    xhr.setRequestHeader('Authorization', 'Basic ' + Ti.Utils.base64encode(username + ':' +password));
 
    xhr.send();
 
};
my problem is i need to get the response and then i want Ti.API.info(); statement should be executed.was not able to make this work pls help

i want the same code to be run in ios and android platfrom


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>