Hi. I’m a complete ember.js beginner. I need to write a local application - ember-cli-nwjs works OK for me, I start it from the /dist folder. I need to place a local JSON file somewhere so it will be available in the /dist/assets folder, e.g. /dist/assests/codebook.json. This file must be modifiable, and reloaded into the application after app restart. Is it possible, please? If yes, how do I read the JSON file into the application, e.g. using $.getJSON ? Thanks. Karel
You can put the json file in the public
folder. All files & folder from the public folder will be copied as-is. Then you can just access it with $.getJSON("/path/to/data.json")
(if your file is /public/path/to/data.json).
Francesco, it works like a charm. Thank you very much for your help. Karel
Hi. Loading json file from public folder works perfect, but only when the application is running in the server mode (ember serve). But unfortunately I need to run it from a file folder using index.html
When I start it locally, I get this error:
XMLHttpRequest cannot load file:///data/tarify.json. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
Is there a way to load a file ‘locally’ from the public folder, please? Thanks Karel
I admit I would not move an inch ahead without this forum.