Cordova android:在 angular js 应用程序中出现 404 错误
Cordova android: Getting 404 error in angular js app
我正在 android 使用 cordova 和 angularjs(onsenui 前端框架)开发应用程序。
这是我从服务器
获取一些数据的获取请求
$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请求returns出现如下错误
{"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"}"
还在我的 php
中启用了 CORS
<?php
header("Access-Control-Allow-Origin: *");
//api request response
?>
为什么我的应用 运行 在 phone 时出现此错误?
安装Cordova白名单插件解决我的问题
我正在 android 使用 cordova 和 angularjs(onsenui 前端框架)开发应用程序。 这是我从服务器
获取一些数据的获取请求$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请求returns出现如下错误
{"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"}"
还在我的 php
中启用了 CORS<?php
header("Access-Control-Allow-Origin: *");
//api request response
?>
为什么我的应用 运行 在 phone 时出现此错误?
安装Cordova白名单插件解决我的问题