I am new to JavaScript and I was looking for a solution to this problem:
I have names and numbers that are written to the data.json file in the same directory as in my JavaScript file. I am looking for a few minutes to verify that data.json and update the HTML p tag with the changes.
My HTML block is as follows:
...
<body>
<p id="mydata">
</p>
</body>
...
My data.json look like this:
[{"Name":"Charlie","Number":"5"},{"Name":"Patrick","Number":"3"}]
My Javascript block looks like this:
...
setInterval(function(){
var json =
document.getElementById('mydata').innerHTML = json;
},300000);
source
share