diff --git a/Monitor/Pages/_Layout.cshtml b/Monitor/Pages/_Layout.cshtml index 4d99b31..a4ab6fc 100644 --- a/Monitor/Pages/_Layout.cshtml +++ b/Monitor/Pages/_Layout.cshtml @@ -172,6 +172,13 @@ var errCount = []; var interval; var loadWidgets = function () { + // Clear exisitng interval to stop multiple attempts to load at the same time. + if (interval != null) + { + clearInterval(interval); + } + + // Load widgets $('[data-toggle="tooltip"]').tooltip(); $("#ticker-widgets").load('@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/TickerWidgets', '', function (responseText, textStatus, XMLHttpRequest) { if (textStatus == 'error') { @@ -184,13 +191,15 @@ } else { errCount["TickerWidgets"] = 0; } + + // Reinstate the interval. + interval = setInterval(function () { loadWidgets(); }, 5000); }); }; $(document).ready(function () { errCount["TickerWidgets"] = 0; loadWidgets(); - interval = setInterval(function () { loadWidgets(); }, 5 * 1000); $('[data-toggle="tooltip"]').tooltip() $('.text-autocolor').autocolor(false);