Reputation: 9
I want to make a local HTML application read and update a JSON file and use its content to display HTML content. Alas, I'm stuck at the very first step, as I can't seem to setup any sort of test file that simply notices and reads a JSON file. From what I see online, I need to use other libraries. I attempted to use require.js but I can't make it work and the documentation doesn't help me.
I imported the require.js with a tag and attempt to launch something out of what I got from the documentation, but there's nothing to do. It doesn't look like it's willing to take .json files.
requirejs([
'example'
], function(example) {
const config = require('./config.json')
});
My issue is to get the program to read the file. From there I believe I can make the display of it, but this JS thing is all alien to me.
Upvotes: 0
Views: 101
Reputation: 816
The recommended way would be to run a web server or use something like Electron and build a desktop app (as @chrisG points out in the comments). But if you wanna do this in the browser without an web server you could do something like:
--allow-file-access-from-files
(or however you allow local file access in your browser of choice)Upvotes: 1