From 3e897159801668fb06e79017866e54009c3485ed Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 11 Dec 2014 20:07:51 -0500 Subject: [PATCH] Provide more descriptive ajax error messages --- js/crm.ajax.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/js/crm.ajax.js b/js/crm.ajax.js index 276d02ddfd..2a48af1460 100644 --- a/js/crm.ajax.js +++ b/js/crm.ajax.js @@ -204,10 +204,19 @@ this.options.url = this.options.url || document.location.href; this._originalUrl = this.options.url; }, - _onFailure: function(data) { + _onFailure: function(data, status) { + var msg, title = ts('Network Error'); this.options.block && this.element.unblock(); this.element.trigger('crmAjaxFail', data); - CRM.alert(ts('Unable to reach the server. Please refresh this page in your browser and try again.'), ts('Network Error'), 'error'); + switch (status) { + case 'Forbidden': + title = ts('Access Denied'); + msg = ts('Ensure you are still logged in and have permission to access this feature.'); + break; + default: + msg = ts('Unable to reach the server. Please refresh this page in your browser and try again.'); + } + CRM.alert(msg, title, 'error'); }, _onError: function(data) { this.element.attr('data-unsaved-changes', 'false').trigger('crmAjaxError', data); @@ -263,8 +272,8 @@ that._handleOrderLinks(); that.element.trigger('crmLoad', data); that.options.crmForm && that.element.trigger('crmFormLoad', data); - }).fail(function() { - that._onFailure(); + }).fail(function(data, msg, status) { + that._onFailure(data, status); }); }, // Perform any cleanup needed before removing/replacing content -- 2.25.1