0

I have a local webpage that loads a large json database file by having a file called data.jsonp containing data={json dictionary of stuff}, then importing said file in my HTML with <script src="data.jsonp"></script> to load data as a variable containing the whole database, which works.

I now need to be able to change the content of the data.jsonp file and have the data variable update without refresing the whole website. I can edit data.jsonp, but how do I apply this change to the data variable?

1 Answers1

0

Add another <script> tag to the DOM, and it will reload the script:

let script = document.createElement("script");
script.src = "data.jsonp";
document.head.appendChild(script);
Barmar
  • 741,623
  • 53
  • 500
  • 612