1

Is there an option to enable Chrome or the Internet Explorer to load (via ajax-get) an JSON file from the local harddisk?

Firefox does so by default. Internet Explorer says 'premission denied' at the line

request.open(method, url, true);
Matthias
  • 908
  • 1
  • 7
  • 22

2 Answers2

1

There are no simple cleaner way you can do this, you have to do some server-side coding.

I suggest you node.js this is very handy for this type of IO operations.

It looks very difficult for first time but it is very handy.

  1. Download and install nodejs.

  2. create a simple project to handle this.

    In the directory you want files to get (e.x. D:\myfiles), create one file server.js, content of that js file would be following

var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic("./")).listen(105);
  1. open command promp from and get to this directory (D:\myfiles)
  2. Run these two commands npm install connect and npm install serve-static (up to this, is one time process)
  3. Run node server.js - That's all your server is ready and running
  4. call http://localhost:105/<file name> and you can get any files within that directory.
Akshay
  • 3,558
  • 4
  • 43
  • 77
  • Thank you very much for your detailed answer. In my specific case I have a C programm which gernerates me data and writes them into a json file. The html site plots the data with d3js. For this your suggestion has a huge overhead. Therefore it would be simpler to generate a javascript file. – Matthias Nov 13 '14 at 11:39
-1

For chrome you can use following command line flags, taken from following question

  • --allow-file-access-from-files
  • --disable-web-security

As noted in that question you need to restart your all chrome browsers.

For internet explorer, trick is to use ActiveX version of the XMLHttpRequest object. See following link.

Community
  • 1
  • 1
Atilla Ozgur
  • 14,339
  • 3
  • 49
  • 69