Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (xhr.send)
Viewing all articles
Browse latest Browse all 5

xhr.send() returns immediately before onload is called

$
0
0

I have a createHTTPClient that calls a URL and after calling the xhr.send(); it immediately returns before the onload/error is called and the response is checked. Is there a way to make the xhr.send() not return until these functions have completed their tasks and I have some data to return? The async flag (true/false) in the xhr.open does not seem to make a difference.

function getData() {
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function() {
...
}
xhr.error = function(e) {
...
}
xhr.open('GET', 'http://www.google.com',true);
xhr.send(); 
};

Viewing all articles
Browse latest Browse all 5

Trending Articles



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