Reputation: 355
I am working with Titanium Studio and I have to make an HTTP get request to Couchdb. This is my code:
var url ="http://192.168.0.152:5985/hello_world/00a271787f89c0ef2e10e88a0c0001f4";
var json;
var xhr = Ti.Network.createHTTPClient({
onload: function() {
Ti.API.info("Received text: " + this.responseText);
json = JSON.parse(this.responseText);
},
onerror: function(e) {
Ti.API.debug("STATUS: " + this.status);
Ti.API.debug("TEXT: " + this.responseText);
Ti.API.debug("ERROR: " + e.error);
alert('There was an error retrieving the remote data. Try again.');
},
timeout:5000
});
xhr.open("GET", url);
xhr.send();
The operation go in time out..
Upvotes: 1
Views: 2330
Reputation: 240
the code works fine. I tested it with a different URL. first check the URL in a web browser to see how much it takes to load, then increase the timeout value. if it works fine try opening the URL in the browser of the simulator, you may find that it's an IP problem
Upvotes: 2