Ajax error on mobile browsers

1.2k Views Asked by At

Hi the below code works well on desktop, but ajax call fails on mobile browsers. On mobile it returns "number". Any help will be appreciated. On desktop i have tried on firefox, IE and chrome. On Android tried on dolphin, chrome and samsung inbuilt browser.

var url="../eXploreAPI/api";
    function login(){
        var number , password;
        number = $("#number1").val();
        password = $("#password1").val();
        var token= btoa(number +":"+password);
        $.ajax({
                url: url,
                headers: {
                    'token':token
                },
                type: 'POST', 
                datatype: 'application/x-www-form-urlencoded',
                data: {
                    requestName: "login" ,
                    mobileno : number,
                    password : password
                },
                success: function (data) {
                    var d=jQuery.parseJSON(data);

                    var item=d.item;
                    var val = item.userid;
                    getdetails(val);

                },
                error: function () {
                    alert(number);
                }
        });



    }
    function getdetails(val){
        localStorage.setItem("shop_id",val);
        window.location.href="../page4.html";
        return false;
    }
1

There are 1 best solutions below

0
On

in your error callback put this line alert(data.status); This will give you exact error code. I think this may be issue with cross browser compatibility