[英]Cordova android: Getting 404 error in angular js app
I am developing an application in android using cordova and angularjs (onsenui front end framework). 我正在使用cordova和angularjs(onsenui前端框架)在android中开发应用程序。 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 情况1
When running app in browser i will get the desired output (get request works fine). 在浏览器中运行应用程序时,我将获得所需的输出(获取请求的效果很好)。
CASE 2 案例2
Build my app in android platform and import to android studio. 在android平台上构建我的应用,然后导入android studio。 At this point the http get request returns the following error
此时,http get请求返回以下错误
{"data":"","status":404,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":" http://example.com?action=getlotterylist ","headers":{"Accept":"application/json, text/plain, / "}},"statusText":"Not Found"}"
{“数据”:“”,“状态”:404,“配置”:{“方法”:“ GET”,“ transformRequest”:[null],“ transformResponse”:[null],“ url”:“ http: //example.com?action=getlotterylist “,”标题“:{”接受“:”应用程序/ json,文本/纯文本, / “}},” statusText“:”未找到“}”
Also enabled CORS in my php 还启用了我的PHP中的CORS
<?php
header("Access-Control-Allow-Origin: *");
//api request response
?>
Why i am getting this error when running my app in phone? 为什么在手机上运行我的应用程序时出现此错误?
Installing Cordova white-list plugin solves my problem 安装Cordova白名单插件可以解决我的问题
https://github.com/apache/cordova-plugin-whitelist https://github.com/apache/cordova-plugin-whitelist
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.