forked from CGM_Public/pretix_original
Display errors caused in AJAX requests
This commit is contained in:
@@ -42,10 +42,12 @@ function async_task_error(jqXHR, textStatus, errorThrown) {
|
||||
"use strict";
|
||||
waitingDialog.hide();
|
||||
// TODO: Handle status codes != 200
|
||||
// if(jqXHR.status == 500) {
|
||||
// } if(jqXHR.status == 403) {
|
||||
// } if(jqXHR.status == 503) {
|
||||
// }
|
||||
var c = $(jqXHR.responseText).filter('.container');
|
||||
if (c.length > 0) {
|
||||
ajaxErrDialog.show(c.first().html());
|
||||
} else {
|
||||
alert(gettext('Unknown error.'));
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
|
||||
@@ -19,6 +19,8 @@ $(function () {
|
||||
$("#voucher-box").slideDown();
|
||||
$("#voucher-toggle").slideUp();
|
||||
});
|
||||
|
||||
$("#ajaxerr").on("click", ".ajaxerr-close", ajaxErrDialog.hide);
|
||||
});
|
||||
|
||||
var waitingDialog = {
|
||||
@@ -32,3 +34,17 @@ var waitingDialog = {
|
||||
$("body").removeClass("loading");
|
||||
}
|
||||
};
|
||||
|
||||
var ajaxErrDialog = {
|
||||
show: function (c) {
|
||||
"use strict";
|
||||
$("#ajaxerr").html(c);
|
||||
$("#ajaxerr .links").html("<a class='btn btn-default ajaxerr-close'>"
|
||||
+ gettext("Close message") + "</a>");
|
||||
$("body").addClass("ajaxerr");
|
||||
},
|
||||
hide: function () {
|
||||
"use strict";
|
||||
$("body").removeClass("ajaxerr");
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user