Suddenly can not connect to web services in Cordova app

657 Views Asked by At

I am Working in visual studio 2015 Cordova App . My JQuery code which was able to connect to web services was running successfully . Suddenly it can't connect to web services . When i test my web service in Advanced Rest Client it worked fine . I didn't make any thing to my code (or I didn't know what i made ) here is my code :

$("#login").click(function() {
    if ($("#password-field").val() == '' || $("#password-field").val() == '') {
        alert("Please Fill Required Fields !");
    } else {
        var url = "http://41.128.183.109:9090/api/Data/getloginer";
        var data = {
            medid: $("#medicalid").val(),
            pass: $("#password-field").val()
        };
        $.ajax({
            url: url,
            type: 'Get',
            data: data,
            success: function(data) {

                if (JSON.stringify(data) != "[]") {
                    localStorage.setItem("medical", (data[0].Medical_id));
                    localStorage.setItem("Type", (data[0].Type));
                    localStorage.setItem("Name", (data[0].Name));
                    localStorage.setItem("loged", "loged");
                    window.location.href = "home.html";
                } else {

                    // alert("Please make sure for you data !");
                    alert("Please make sure for you data !");
                }
            },
            error: function(data) {
                alert(JSON.stringify(data));
            }
        });
    }
});

when i run it i get an error (readystate 0 status 0 statustext error ) .

1

There are 1 best solutions below

0
On

Have you updated cordova recently? In the last versions a whitelist plugin is needed to connect to external resources:

https://github.com/apache/cordova-plugin-whitelist

Check if this is your problem.