Borshon saydur rahman
Borshon saydur rahman

Reputation: 130

Ajax request fails in Cordova application Visual studio

I am Using visual studio 2015 to build android application using cordova. It works fine in the emulator. but when i am releasing it ajax request is failing where as same thing works on emulator.no error is seen in log but only the ajax error.

var url = 'http://oployeelabs.net/demo/demo_doctorola/doctorola-server/index.php/doctor_panel_api/validation_modified/format/json';
load();
$.ajax({
    url: url,
    data: { cell_no: phone, pass: pass },
    method: 'POST',
    dataType: 'json',
    success: function (data) {
        alert();
        if (data == "false")
        {
            alert("Wrong password");
        }
        else
        {
            localStorage.doctorid = data[0].id;
            localStorage.userinfo = JSON.stringify(data);
            $.ajax({
                url: "http://oployeelabs.net/demo/demo_doctorola/doctorola-server/index.php/api/information/meta-info/location/id/"+data[0].id+"/username/9791a47fef07649b1c3e70749e898153/password/2d593e25d0560b19fd84704f0bd24049/format/json",
                method: 'GET',
                dataType: 'json',
                success: function (dt) {

                    localStorage.Chamberinfo = JSON.stringify(dt);
                    mainView.router.loadPage({ url: 'menu.html', ignoreCache: true, reload: true })
                    $('.toolbar').removeClass('hide');

                }
            });


        }

        //if (data === "ok") {
        //    $(".confirm_appointment").remove();
        //    var anc = "<a id='confirm_appointment' class='confirm_appointment' style='opacity: 0;' href='confirm.html' data-context='{\"slot_id\": \"" + slot_id + "\",\"slot_date\": \"" + slot_date + "\", \"email\": \"[email protected]\"}'>profile</a>";
        //    $(document).find('.page_content').append(anc);
        //    $(".confirm_appointment")[0].click();
        //}
        //else {
        //    myApp.hidePreloader();
        //    myApp.alert("", "Sorry, this slot has been booked. Please try with another slot.");
        //}
    },
    error: function (xhr, status, exception) {
        alert(xhr.responseText+" "+status+" "+ exception);
        console.log("Error: " + xhr.responseText + " - " + exception);
    },
    complete: function () {
        myApp.hidePreloader();
        unload();
    }
});

Upvotes: 1

Views: 127

Answers (1)

Borshon saydur rahman
Borshon saydur rahman

Reputation: 130

Strangely it worked after i uninstalled whitelist plugin and installed it again. i dont know why but i think its a bug of cordova.

Upvotes: 1

Related Questions