Phonegap ajax login fail

87 Views Asked by At

i have a an app that runs with phonegap. When i try to login using phonegap desktop app server the login works. But when i upload the app on phonegap build and i download the apk, install the app the login recive "failure". So using phonegap desktop app works, using build login fails, can you help me please? Here is the code:

<form class="login-form test"  method="POST">
        <h3 class="form-title">Sign In</h3>
        <div class="alert alert-danger display-hide">
            <button class="close" data-close="alert"></button>
            <span>
            Enter any username and password. </span>
        </div>
        <div class="form-group">
            <!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
            <label class="control-label visible-ie8 visible-ie9">Email</label>
            <input class="form-control form-control-solid placeholder-no-fix" type="text" autocomplete="off" placeholder="Email" name="username" id="username"/>
        </div>
        <div class="form-group">
            <label class="control-label visible-ie8 visible-ie9">Parola</label>
            <input class="form-control form-control-solid placeholder-no-fix" type="password" autocomplete="off" placeholder="Parola" name="password" id="password"/>
        </div>

        <div class="form-actions">
            <button type="submit" class="btn btn-success uppercase" id="login">Login</button>

        </div>
        <div id="msg"></div>
    </form>

<script>
$(function() {

    $("button#login").click(function(e){
        e.preventDefault();
            $.ajax({
            type: "POST",
            url: "http://porsche.e-twow.uk/mobile/login.php", 
            data: $('form.test').serialize(),
            dataType: 'json',
            success: function(data){
                    if(data.error == "error_msg")
                        {
                        $("#msg").html('Email-ul sau parola nu corespund.')
                        }
                    else if (data == "obligatoriu")
                        {
                        $("#msg").html('Va rugam completati emailul si parola')
                        }
                        else if (data == "captcha")
                        {
                        $("#msg").html('Va rugam bifati "Im not a robot"')
                        }
                        else if ( data.tip ==4 )
                        {

               window.location.replace("rezervari.html");
               Cookies.set('id_user', data.id_user , { expires: 7 });
                   }
                   else if ( data.tip ==3 )
                        {

               window.location.replace("admin/clienti.php");
                   }

                                   },

        error: function(){
            alert("failure");
            }
              });
    });
});
</script>
0

There are 0 best solutions below