How to refresh a page whenever my json data file changes

前端 未结 5 464
甜味超标
甜味超标 2020-12-29 14:26

So I\'ve got this local file named \'data.json\' containing various data. I want to refresh my page only when some data in the json file changes. Appreciate your help if you

5条回答
  •  长情又很酷
    2020-12-29 14:42

    Create a timer, fetch the json file every X milliseconds. If the json contents has changed since the last fetch, reload the page. The sample code below uses JQuery to fetch the json file, and checks every 2000 milliseconds. Be sure the json file contains valid json.

    
    
    
    
    

提交回复
热议问题