retry page stats in 5 seconds if they fail
authorScott Baker <smbaker@gmail.com>
Mon, 9 Jun 2014 23:03:35 +0000 (16:03 -0700)
committerScott Baker <smbaker@gmail.com>
Mon, 9 Jun 2014 23:03:35 +0000 (16:03 -0700)
planetstack/core/static/page_analytics.js

index 6f35b6b..0b1357b 100644 (file)
@@ -58,12 +58,15 @@ function updatePageAnalytics() {
     url: url,
     dataType : 'json',
     type : 'GET',
-    success: function(newData)
-    {
+    success: function(newData) {
         updatePageAnalyticsData(newData);
+        setTimeout(updatePageAnalytics, 30000);
+    },
+    error: function() {
+        console.log("error retrieving statistics; retry in 5 seconds");
+        setTimeout(updatePageBandwidth, 5000);
     }
 });
-    setTimeout(updatePageAnalytics, 30000);
 }
 
 // ----------------------------------------------------------------------------
@@ -87,12 +90,15 @@ function updatePageBandwidth() {
     url : url,
     dataType : 'json',
     type : 'GET',
-    success: function(newData)
-    {
+    success: function(newData) {
         updatePageBandwidthData(newData);
+        setTimeout(updatePageBandwidth, 30000);
+    },
+    error: function() {
+        console.log("error retrieving statistics; retry in 5 seconds")
+        setTimeout(updatePageBandwidth, 5000);
     }
 });
-    setTimeout(updatePageBandwidth, 30000);
 }
 
 $( document ).ready(function() {