diff --git a/templates/exam_overview_js.html b/templates/exam_overview_js.html
index d27d785d..ebaa05a3 100644
--- a/templates/exam_overview_js.html
+++ b/templates/exam_overview_js.html
@@ -22,9 +22,22 @@
// show some message according to the response.
// For eg. A message box showing that the status has been changed
})
- .fail(function (data) {
- console.log(data)
- toastr.error(`Failed to change state
${data.responseJSON.status}`);
+ .fail(function (jqXHR) {
+ console.log(jqXHR)
+ var msg = 'Unknown error';
+ try {
+ if (jqXHR && jqXHR.responseJSON && jqXHR.responseJSON.status) {
+ msg = jqXHR.responseJSON.status;
+ } else if (jqXHR && jqXHR.responseText) {
+ // fallback to raw responseText (may be HTML)
+ msg = jqXHR.responseText;
+ } else if (jqXHR && jqXHR.statusText) {
+ msg = jqXHR.statusText;
+ }
+ } catch (e) {
+ console.error('Error parsing failure response', e);
+ }
+ toastr.error(`Failed to change state
${msg}`);
})
.always(function () {
console.log('[Done]');