Dimitris Dimitris - 4 months ago 10
Javascript Question

How to read a local json file?

I have seen similar questions here but I just can't understand them.

I am building a small web page and I want to read a .json file from my file system and get the object in it.

The web page is also local and the .json file is in the same folder as the .html file.

How to do that on my Ubuntu machine without using any servers and without jquery if it is possible?

Answer

You can simply append a <script> tag to your page, pointing the SRC to the local .js file in the same folder. You don't need to use Ajax.