From a51d3987e87637e62ba930871a73ef3d0fa995c5 Mon Sep 17 00:00:00 2001 From: Gyorgy Balassy Date: Tue, 16 Aug 2016 03:59:59 +0200 Subject: [PATCH] ADDED: The status bar changes to red and displays an error message when an Ajax call fails. --- BuildMonitor/Content/Site.css | 4 ++++ BuildMonitor/Scripts/Project/home.js | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/BuildMonitor/Content/Site.css b/BuildMonitor/Content/Site.css index c8e0017..24ab463 100644 --- a/BuildMonitor/Content/Site.css +++ b/BuildMonitor/Content/Site.css @@ -225,4 +225,8 @@ html * { .space { padding-left: 20px; +} + +.update-failure { + color: #FB1B45; } \ No newline at end of file diff --git a/BuildMonitor/Scripts/Project/home.js b/BuildMonitor/Scripts/Project/home.js index d9e1612..ff9addd 100644 --- a/BuildMonitor/Scripts/Project/home.js +++ b/BuildMonitor/Scripts/Project/home.js @@ -5,6 +5,7 @@ setInterval(function () { $.ajax({ url: '/Home/GetBuilds', + cache: false, success: function (data) { $.each(data.Builds, function (i, build) { var divId = "#BuildDiv-" + build.Id; @@ -12,9 +13,13 @@ buildDiv.replaceWith(build.Content); }); - $("#last-updated").text(data.UpdatedText); + $("#last-updated").text(data.UpdatedText).removeClass("update-failure"); }, - cache: false + error: function (xhr, textStatus, errorThrown) { + $("#last-updated") + .text("Ajax error: " + textStatus + ". Details: " + errorThrown + " (HTTP " + xhr.status + ").") + .addClass("update-failure"); + } }); }, 15000); }); \ No newline at end of file