Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (titanium.network.httpclient)
Viewing all articles
Browse latest Browse all 13

httpClient problem android emulator

$
0
0

i've been developing an iphone,ipad and android application but the following code works perfectly fine in the first two platforms I mentioned but in android it jumps directly to the function xhr.onerror() the code is bellow

var URL ="http://localhost:3000/icuponcels/list?latitude="+25.650657+"&longitude="+-100.287216;
 
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function()
{   
    json = JSON.parse(this.responseText);
 
    Ti.API.info(json);
};
xhr.onerror = function()
{
    var internet=Ti.UI.createAlertDialog({
        title:'Por el momento esta funcion no esta disponible por problemas de conexion a internet',
        buttonNames: ['OK']
    });
    Ti.API.info("error en xhr");
    internet.show();
};
xhr.open("GET",URL);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Accept', 'application/json');
xhr.send();

Viewing all articles
Browse latest Browse all 13

Trending Articles



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