我正在使用cordova和angularjs(onsenui前端框架)在android中开发应用程序。 这里是我的GET请求,在浏览器中,我将获得所需的输出运行的应用程序从服务器科尔多瓦android:在角度js应用程序中获取404错误
$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
获取一些数据(GET请求正常工作)。
CASE 2
建立我在Android平台和导入到Android工作室应用。 此时HTTP GET请求返回以下错误
{ “数据”: “”, “状态”:404, “配置”:{ “方法”: “GET”, “transformRequest”:[ null“,”transformResponse“:[null],”url“:”http://example.com?action=getlotterylist“,”headers“:{”Accept“:”application/json, text/plain,/“}},”statusText“未找到 “}”
也使CORS在我的PHP
<?php
header("Access-Control-Allow-Origin: *");
//api request response
?>
为什么我在手机中运行我的应用时出现此错误?
谢谢!我遇到了同样的问题,变得非常沮丧。添加白名单插件也为我解决了。 – user2233677