mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-08 17:12:25 +03:00
The generic error handler callback can now display non-JSON responses (#836).
This commit is contained in:
parent
4f1c39b564
commit
8f1e82019f
1 changed files with 8 additions and 2 deletions
|
@ -301,7 +301,13 @@ window.GeneralFunctions = window.GeneralFunctions || {};
|
|||
exports.ajaxFailureHandler = function (jqXHR, textStatus, errorThrown) {
|
||||
console.error('Unexpected HTTP Error: ', jqXHR, textStatus, errorThrown);
|
||||
|
||||
var response = JSON.parse(jqXHR.responseText);
|
||||
var response;
|
||||
|
||||
try {
|
||||
response = JSON.parse(jqXHR.responseText); // JSON response
|
||||
} catch(error) {
|
||||
response = { message: jqXHR.responseText }; // String response
|
||||
}
|
||||
|
||||
if (!response) {
|
||||
return;
|
||||
|
@ -311,7 +317,7 @@ window.GeneralFunctions = window.GeneralFunctions || {};
|
|||
|
||||
$('<div/>', {
|
||||
'class': 'well',
|
||||
'text': response.message
|
||||
'html': response.message || '→ No error information provided.'
|
||||
})
|
||||
.appendTo('#message_box');
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue