Hello Ionic Community,
i’m having troubles with my project, i need to read from a server a simple json request, but i had this error : XMLHttpRequest cannot load http://localhost:8443/RESTfulExample/json/product/get. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access
.
I have tried to get the data from another page,just for test my controller (from this server https://public-api.wordpress.com/rest/v1/freshly-pressed/ ) and it work fine.
This is my code for instruct the controller:
app.controller('controlloVista', function($scope , $http , $templateCache , vettoreCose ){
$scope.listaDiCose = vettoreCose.getTutto();
$scope.code = null;
$scope.response = null;
$scope.method = "get";
$scope.url = "http://localhost:8443/RESTfulExample/json/product/get"//"http://127.0.0.1:8443/RESTfulExample/json/product/Alfredo";
$scope.datiRicevuti = [];
//$scope.url = "https://public-api.wordpress.com/rest/v1/freshly-pressed/";
//$scope.url = "/json/file.json";
$http({method: $scope.method, url: $scope.url, cache: $templateCache}).
success(
function(data, status)
{
$scope.status = status;
$scope.datiRicevuti = data;
}).
error(
function(data, status)
{
$scope.datiRicevuti = data || "Request failed";
$scope.status = status;
});
});