Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (android)
Viewing all articles
Browse latest Browse all 7655

http connection problem

$
0
0

hi, I am on working on a titanium app for android. from the app i am trying to connect to my localhost. But its showing an error like the connection is refused or something like that. Here I am providing my code.

var loginReq = Titanium.Network.createHTTPClient();
loginReq.onload = function()
{
    var json = this.responseText;
    Ti.API.info(this.responseText)
    var response = JSON.parse(json);
    if (response.logged == true)
    {
        alert("Welcome " + response.name + ". Your email is: " + response.email);
    }
    else
    {
        alert(response.message);
    }
};
 
loginReq.onerror = function()
{
    alert("Network error");
};
 
//login button action
loginBtn.addEventListener('click',function(e)
{
    if (username.value != '' && password.value != '')
    {
        loginReq.open("POST","http://localhost/testapp/post_auth.php");
        var params = {
            username: username.value,
            password: password.value
        };
        loginReq.send(params);
    }
    else
    {
        alert("Username/Password are required");
    }
});

Viewing all articles
Browse latest Browse all 7655

Trending Articles



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