diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 72d2ae51c..3b92e5b2f 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -222,12 +222,23 @@ processNotificationHeader: function(req) { var header = req.getResponseHeader('X-Icinga-Notification'); - if (typeof header === 'undefined' || ! header) return false; + if (! header) return false; var parts = decodeURIComponent(header).split(' '); this.createNotice(parts.shift(), parts.join(' ')); return true; }, + processRedirectHeader: function(req) { + var redirect = req.getResponseHeader('X-Icinga-Redirect'); + if (! redirect) return false; + this.icinga.logger.debug( + 'Got redirect for ', req.$target, ', URL was ' + redirect + ); + redirect = decodeURIComponent(redirect); + this.loadUrl(redirect, req.$target); + return true; + }, + /** * Handle successful XHR response */ @@ -255,14 +266,7 @@ this.processNotificationHeader(req); var redirect = req.getResponseHeader('X-Icinga-Redirect'); - if (redirect) { - this.icinga.logger.debug( - 'Got redirect for ', req.$target, ', URL was ' + redirect - ); - redirect = decodeURIComponent(redirect); - this.loadUrl(redirect, req.$target); - return; - } + if (this.processRedirectHeader(req)) return; // div helps getting an XML tree var $resp = $('