The above code fetches a .json
file and displays the data in an HTML file. Currently, the work is done by fetching the data from the <script>
.
The current issue is that the initially placed content on the screen shows the default values, and after 1-2 seconds,
the content is replaced with the values processed by innerText in the script. For example, the element with document.
getElementById('name')
initially shows JohnDoe
, and after a delay, it is updated to Tom
fetched from the .json
file.
Additionally, about 1 in 10 times, the data is not fetched, causing issues.
I want to change the method so that the data is fetched and displayed simultaneously with the screen loading,
rather than being delayed by asynchronous processing. Is there a way to achieve this?
I made that code.
I tried to do the best, but I couldn’t make a better way than that.
3
if you move the creation of editor var editor = new JSONEditor(...)
to before the line you have editor.on('ready')
should be more immediate