showing results for - "javascript update page when json file changes"
Hawa
05 Feb 2018
1<html>
2<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
3<script>
4    var previous = null;
5    var current = null;
6    setInterval(function() {
7        $.getJSON("data.json", function(json) {
8            current = JSON.stringify(json);            
9            if (previous && current && previous !== current) {
10                console.log('refresh');
11                location.reload();
12            }
13            previous = current;
14        });                       
15    }, 2000);   
16</script>
17</html>
18
similar questions