Skip to content

Instantly share code, notes, and snippets.

@Soben
Last active December 27, 2015 14:39
Show Gist options
  • Save Soben/7341867 to your computer and use it in GitHub Desktop.
Save Soben/7341867 to your computer and use it in GitHub Desktop.
If the server is still accessible, refresh the page, otherwise, check again in another N seconds. -- Flying Pig Taphouse script for their menu. We didn't want to lose their menu on the screen if the internet went down.
var time_to_wait = 600000; // 10 minutes
/**
* refresh_page ()
*
* Runs an AJAX call to check up on the server before refreshing the page.
*/
function refresh_page () {
// Let's make the AJAX call to check to see if the server is still available.
$.ajax({
url : '<?php echo admin_url( 'admin-ajax.php'); ?>',
data : {
action : 'serveraccessible'
}
})
.done(function () {
// It is! Let's refresh the page to get the latest data.
window.location = window.location;
})
.fail(function() {
// Oh bummer. Well, let's reset the timer to check again.
setTimeout('refresh_page()', time_to_wait);
});
} // function
(function($){
// Get the ball rolling.
setTimeout('refresh_page()', time_to_wait);
})(jQuery);
Copy link

ghost commented Nov 6, 2013

bootstrap-builder-boilerplate-+++is+++is+++is,,,---te---te---te,,,

Copy link

ghost commented Nov 6, 2013

bootstrap-builder-boilerplate-+++is+++is+++is,,,---te---te---te,,,

Copy link

ghost commented Nov 6, 2013

bootstrap-builder-boilerplate-+++is+++is+++is,,,---te---te---te,,,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment