Skip to content

Instantly share code, notes, and snippets.

@KingScooty
Last active November 26, 2015 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KingScooty/188b0c351d99018bb4a5 to your computer and use it in GitHub Desktop.
Save KingScooty/188b0c351d99018bb4a5 to your computer and use it in GitHub Desktop.
Periodically load JSON after initial load and update a chart.
var updateChart = function updateChart () {
$.getJSON( "URL.json", function( data ) {
// callback for event to take place after JSON has been retrieved.
// data is the object containing the JSON.
});
};
var init = function init () {
updateChart();
};
var cronJob = {
interval: 0,
createInterval: function() {
this.interval = setInterval(updateChart, 500);
},
clearInterval: function() {
clearInterval(this.interval);
}
};
init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment