0

I know that this question was previously asked here: Read local file in AngularJS

But I was just wondering if anyone has a better method than simple making a http request for the local file. I am currently using the http call method of opening a file, but the problem is that this method does not seem to work on chrome unless I host the json file on a web server. It will, however, work on firefox.

Does anyone have a solution that works well on chrome and does not host the file on a server of some sort? Any ideas?

Community
  • 1
  • 1
Ninja
  • 1,012
  • 3
  • 14
  • 29
  • install a localhost server on your computer, lots of packages available for it – charlietfl Sep 15 '14 at 22:43
  • It doesn't mean your code is bad; I'm pretty sure in this specific situation Chrome is just being strict about the local file. If it is working in Firefox, you should be good if you're testing locally now and putting on a web server later. – thecommonthread Sep 15 '14 at 22:48
  • 1
    [Chrome can be opened with `file://`-based Ajax enabled.](http://stackoverflow.com/questions/4208530/xmlhttprequest-origin-null-is-not-allowed-access-control-allow-origin-for-file) But, HTTP is based on having client and server. There are also [numerous options for starting simple, static HTTP servers](https://gist.github.com/willurd/5720255). – Jonathan Lonowski Sep 15 '14 at 22:59
  • you can use an to read local files. – dandavis Sep 15 '14 at 23:52

1 Answers1

0

Might try WAMP (for Windows) or MAMP (for Mac).

thecommonthread
  • 395
  • 4
  • 14