Help with XMLHttpRequest and json requests


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 ) 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"//"";
  $scope.datiRicevuti = [];
  //$scope.url = "";
  //$scope.url = "/json/file.json";
  $http({method: $scope.method, url: $scope.url, cache: $templateCache}).
            function(data, status) 
                $scope.status = status;
                $scope.datiRicevuti = data;
            function(data, status) 
                $scope.datiRicevuti = data || "Request failed";
                $scope.status = status;





This is probably because the server side (!) is not handling the request correctly and not returning an ‘Access-Control-Allow-Origin’ header. You might want to check in your browser while running the app what is send to and received from the server, and configure the server accordingly. See also [this article][1] for additional info.



Thanks…for se rapid response I will keep you updated…



It worked? already I tried many ways and I can not get a json