Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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>
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to get nth tr in js 
Javascript :: make a circle in javascript 
Javascript :: for (var i = 0; i < 3; i++) { setTimeout(function() { console.log(i); }, 1000 + i); } 
Javascript :: react onpaste get value 
Javascript :: discord js kick command 
Javascript :: array[-1] not working 
Javascript :: find in array and return true or false react js 
Javascript :: firebase ststokenmanager return undefined 
Javascript :: change bulk url in elementor 
Javascript :: javascript remove files name starts with 
Javascript :: grepper answer 
Javascript :: Refresh a kendo ui widget, when options on AngularJS $scope change 
Javascript :: moment js formating to one day less using zulu time 
Javascript :: return multiple native element react native 
Javascript :: update mongoose 
Javascript :: https://stackoverflow.com/questions/19380738/mongoose-nested-query-on-model-by-field-of-its-referenced-model 
Javascript :: custom render contenful rich text rendering 
Javascript :: swift read json from url 
Javascript :: likedislike mangodb 
Javascript :: angular data table push not working 
Javascript :: convert milliseconds to hours minutes seconds javascript 
Javascript :: how to update a state with an array react 
Javascript :: express plus make router 
Javascript :: java home sdk error 
Javascript :: woo axios 
Javascript :: Jboss heap dump 
Javascript :: navigate between files in react js 
Javascript :: Javascript multiplier function 
Javascript :: js get each pair of values from an array 
Javascript :: show more vs editor shortcut key 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =