Cordova android:在角度js app中获得404错误

iam*_*man 1 javascript android angularjs cordova onsen-ui

我正在使用cordova和angularjs(onsenui前端框架)在android中开发应用程序.这是我从服务器获取一些数据的get请求

$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));
        }
    );
Run Code Online (Sandbox Code Playgroud)

情况1

在浏览器中运行应用程序时,我将获得所需的输出(获取请求正常).

案例2

在android平台上构建我的应用程序并导入到android studio.此时,http get请求返回以下错误

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

在我的php中也启用了CORS

<?php

  header("Access-Control-Allow-Origin: *");
 //api request response
?>
Run Code Online (Sandbox Code Playgroud)

为什么我在手机中运行我的应用程序时出现此错误?

iam*_*man 8

安装Cordova白名单插件解决了我的问题

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