Answers for "javascript update page when json file changes"

0

javascript update page when json file changes

<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
    var previous = null;
    var current = null;
    setInterval(function() {
        $.getJSON("data.json", function(json) {
            current = JSON.stringify(json);            
            if (previous && current && previous !== current) {
                console.log('refresh');
                location.reload();
            }
            previous = current;
        });                       
    }, 2000);   
</script>
</html>
Posted by: Guest on September-09-2021

Code answers related to "javascript update page when json file changes"

Code answers related to "Javascript"

Browse Popular Code Answers by Language