Currently, I am working on an android application using Cordova and AngularJS (front-end framework OnsenUI). Below is the code snippet for my GET request to retrieve data from the 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));
}
);
SITUATION 1
When testing the app in a browser, the GET request works perfectly fine.
SITUATION 2
After building the app for the Android platform and importing it into Android Studio, the HTTP GET request encounters the following error:
{"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"}"
I have also enabled CORS in my PHP script:
<?php
header("Access-Control-Allow-Origin: *");
//api request response
?>
What could be causing this error specifically when running the app on a mobile phone?