Phonegap ajax登录失败

时间:2017-12-15 08:33:30

标签: javascript android ajax phonegap-build phonegap-desktop-app

我有一个使用phonegap运行的应用程序。当我尝试使用phonegap桌面应用服务器登录时,登录工作正常。但是当我在phonegap构建上传应用程序并下载apk时,安装应用程序登录重新“失败”。所以使用phonegap桌面应用程序工作,使用构建登录失败,你能帮我吗?这是代码:

<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 个答案:

没有答案