From 1899b9ec7fd0abb40075d47dc6c10d9effea8eed Mon Sep 17 00:00:00 2001 From: Michael Niles Date: Thu, 19 Mar 2015 16:46:23 -0700 Subject: [PATCH 1/2] Solved endless polling issue Browser will stop previous location.reload() action when a new location.reload() action is fired, if the first fire doesn't complete before the second, you get an endless loop of location.reload() that never finishes. --- reloadr.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reloadr.js b/reloadr.js index 659f3aa..9c8df07 100644 --- a/reloadr.js +++ b/reloadr.js @@ -20,7 +20,7 @@ TO USE: include reloadr.js and tell it what to check: '/css/layout.css' ]); */ - +var continue_poll = true; var Reloadr = { options: { frequency: 2000, @@ -70,10 +70,13 @@ var Reloadr = { for (i in urls) this.ajax.call(this, urls[i], function() { if (this > Date.parse(window._Reloadr_LoadTime)) + continue_poll = false; location.reload(); }); - this.go(); + if (continue_poll) { + this.go(); + } }, init: function(options) { window._Reloadr_LoadTime = new Date(); From 365204d4fab4f3f03c32c35484bb9b32b42081bc Mon Sep 17 00:00:00 2001 From: blindmikey Date: Sat, 18 Apr 2015 12:23:26 -0700 Subject: [PATCH 2/2] Updated typo that caused infinite reload --- reloadr.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reloadr.js b/reloadr.js index 9c8df07..2f07073 100644 --- a/reloadr.js +++ b/reloadr.js @@ -69,9 +69,10 @@ var Reloadr = { // check 'em for (i in urls) this.ajax.call(this, urls[i], function() { - if (this > Date.parse(window._Reloadr_LoadTime)) + if (this > Date.parse(window._Reloadr_LoadTime)) { continue_poll = false; location.reload(); + } }); if (continue_poll) {