Skip to content
Snippets Groups Projects
Commit 8d1998dd authored by Ere Maijala's avatar Ere Maijala
Browse files

Fix AJAX fail handlers to not cause JS errors if responseJSON is not defined.

parent 5e2ec98d
No related merge requests found
......@@ -80,9 +80,10 @@ function checkItemStatuses() {
$(".ajax-availability").removeClass('ajax-availability');
})
.fail(function(response, textStatus) {
if (textStatus == "abort") { return; }
$('.ajax-availability').empty();
if (textStatus == 'abort' || typeof response.responseJSON === 'undefined') { return; }
// display the error message on each of the ajax status place holder
$(".ajax-availability").empty().append(response.responseJSON.data).addClass('text-danger');
$('.ajax-availability').append(response.responseJSON.data).addClass('text-danger');
});
}
......
......@@ -11,9 +11,9 @@ function loadResolverLinks($target, openUrl, searchClassId) {
$target.removeClass('ajax_availability').empty().append(response.data);
})
.fail(function(response, textStatus) {
if (textStatus == "abort") { return; }
$target.removeClass('ajax_availability').addClass('text-danger')
.empty().append(response.responseJSON.data);
$target.removeClass('ajax_availability').addClass('text-danger').empty();
if (textStatus == 'abort' || typeof response.responseJSON === 'undefined') { return; }
$target.append(response.responseJSON.data);
});
}
......
......@@ -96,7 +96,7 @@ function registerAjaxCommentRecord() {
$(form).find('input[type="submit"]').button('loading');
})
.fail(function(response, textStatus) {
if (textStatus == "abort") { return; }
if (textStatus == 'abort' || typeof response.responseJSON === 'undefined') { return; }
Lightbox.displayError(response.responseJSON.data);
});
return false;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment