繁体   English   中英

Cordova Android:Angular JS应用中出现404错误

[英]Cordova android: Getting 404 error in angular js app

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

$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));
        }
    );

情况1

在浏览器中运行应用程序时,我将获得所需的输出(获取请求的效果很好)。

案例2

在android平台上构建我的应用,然后导入android studio。 此时,http get请求返回以下错误

{“数据”:“”,“状态”:404,“配置”:{“方法”:“ GET”,“ transformRequest”:[null],“ transformResponse”:[null],“ url”:“ http: //example.com?action=getlotterylist “,”标题“:{”接受“:”应用程序/ json,文本/纯文本, / “}},” statusText“:”未找到“}”

还启用了我的PHP中的CORS

<?php

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

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM