0

I am trying to read a simple file from my PODController in AngularJS:

  <script>
      function PODController($scope, $http) {
        $http.get('POD.json').success(function(data) {
          $scope.results = data.results;
          console.log("Here");
        }).error(function(data, status, headers, config) {
          console.log('error');
        });
      }
    </script>

Just like: Filtering by multiple checkboxes in AngularJS and his example on plunk: http://plnkr.co/edit/lNJNYagMC2rszbSOF95k?p=preview

But it seems like I am getting a:

XMLHttpRequest cannot load file:///Users/simon_zhu/Desktop/initializr/POD.json. Cross origin requests are only supported for HTTP.

Both files are in the same folder and he seems to be doing it fine in his example. Is there something I missed?

4
  • 1
    You need to host your json file on a web server. Commented Sep 11, 2014 at 22:49
  • yea. i missed that it seems. thanks. Commented Sep 11, 2014 at 22:51
  • @Donal - or localserver. Commented Sep 11, 2014 at 22:52
  • not hard to set up a localhost server on your own machine and not hard to find numerous packages for it in web search Commented Sep 11, 2014 at 23:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.