SeasonalShot SeasonalShot - 9 months ago 30
jQuery Question

Javascript doesn't update document in browser

I have a data.json in my server directory. I am using the following code from w3school to show the data in the browser. W3school Snippet Link

<button type="button" onclick="loadDoc()">Change Content</button>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("demo").innerHTML = xhttp.responseText;

};"GET", "/static/data.json", true);

When i click the button, I am able to see the data.json in my webpage. But when i change the data.json and click the button again (without refreshing the page), the updated data isn't shown in the browser.

Am i missing something here?

Answer"GET", "/static/data.json?something=RANDOMGUID", true);