【发布时间】:2015-07-20 06:28:51
【问题描述】:
我正在使用 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请求返回如下错误
{"data":"","status":404,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url": "http://example.com?action=getlotterylist","headers":{"Accept":"application/json, text/plain, /"}},"statusText":"未找到"}"
还在我的 php 中启用了 CORS
<?php
header("Access-Control-Allow-Origin: *");
//api request response
?>
为什么我在手机中运行我的应用程序时收到此错误?
【问题讨论】:
标签: javascript android angularjs cordova onsen-ui