Search code examples
asp.netangularjsionic-frameworkasmx

app login works in chrome, but not on device


i have an ionic app with a login screen. when i enter the correct username and password, it works fine in my pc's chrome. but when i do the same in the device, it gives the following error:

Failed to load resource: the server responded with a status of 404 (Not Found) controllers.js:130 response error is = 

here's my code for controller.js:

$scope.enterlogin = function(usern,pass)
{
    var config = {
      params: { uname: usern, passw: pass }
    }

    var url = 'http://xx.xx.x.xxx/UserService3/WebService1.asmx';
    $http.get(url + '/getUserbyUsername' + '?uname=' + usern + '&passw=' + pass ).success(function(response) {
    // stuff
        console.log('response is = ' + JSON.stringify(response));
        if(response['IsExisting'] == null)
        {
            console.log('null existing = ' + response['IsExisting']);
            alert('Please check your credentials. Account does not exist.');
        }
        else
        {
            console.log('not null existing = ' + response['IsExisting']);
            sharedProperties3.setUserID(response['UserID']);
            console.log('setuserid = ' + sharedProperties3.getUserID());

            $scope.hide();
             if($window.localStorage.getItem('has_run') == '') 
             {
                //do some stuff if has not loaded before
                $window.localStorage.setItem('has_run', 'true');
                $state.go('helpExtra'); 
             }
             else
             {
                 $scope.hide();
                 $state.go('menu.mainMenu');
             }

        }
    })
    .error(function(response) {
    // error stuff
        console.log('response error is = ' + response);
    });

i can see the webservice using my phone's browser/chrome, i've installed the whitelist plugin and added this to my index.html file:

 meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"

what could be the problem?


Solution

  • i added this to config.xml file:

     <access origin="*" />