admin管理员组

文章数量:1431435

I am developing an application in android using cordova and angularjs (onsenui front end framework). Here is my get request to fetch some data from server

$http.get(url+"getlotterylist").then(function(msg){
        $scope.loading=false;
        $scope.items=msg.data;
    },
    function(err){
        alert("error"+JSON.stringify(err));
          console.log("Error"+JSON.stringify(err));
        }
    );

CASE 1

When running app in browser i will get the desired output (get request works fine).

CASE 2

Build my app in android platform and import to android studio. At this point the http get request returns the following error

{"data":"","status":404,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":"","headers":{"Accept":"application/json, text/plain, /"}},"statusText":"Not Found"}"

Also enabled CORS in my php

<?php

  header("Access-Control-Allow-Origin: *");
 //api request response
?>

Why i am getting this error when running my app in phone?

I am developing an application in android using cordova and angularjs (onsenui front end framework). Here is my get request to fetch some data from server

$http.get(url+"getlotterylist").then(function(msg){
        $scope.loading=false;
        $scope.items=msg.data;
    },
    function(err){
        alert("error"+JSON.stringify(err));
          console.log("Error"+JSON.stringify(err));
        }
    );

CASE 1

When running app in browser i will get the desired output (get request works fine).

CASE 2

Build my app in android platform and import to android studio. At this point the http get request returns the following error

{"data":"","status":404,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":"http://example.?action=getlotterylist","headers":{"Accept":"application/json, text/plain, /"}},"statusText":"Not Found"}"

Also enabled CORS in my php

<?php

  header("Access-Control-Allow-Origin: *");
 //api request response
?>

Why i am getting this error when running my app in phone?

Share Improve this question edited Jul 20, 2015 at 6:45 shamon shamsudeen asked Jul 20, 2015 at 6:28 shamon shamsudeenshamon shamsudeen 5,87820 gold badges74 silver badges144 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Installing Cordova white-list plugin solves my problem

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

本文标签: javascriptCordova android Getting 404 error in angular js appStack Overflow