JS handle_ajax_return() helper: fix handling Tpl :: display_ajax_error() response type

This commit is contained in:
Benjamin Renard 2025-01-06 15:47:01 +01:00
parent 6f9f6fe3cf
commit 12217d642e
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -176,6 +176,7 @@ function handle_ajax_return(
"done" in data && "fail" in data && "always" in data "done" in data && "fail" in data && "always" in data
? data.responseJSON ?? {} ? data.responseJSON ?? {}
: data; : data;
if (data.error) alertify.notify(data.error, "error");
if (data.errors) if (data.errors)
$(data.errors).each(function (idx, error) { $(data.errors).each(function (idx, error) {
alertify.notify(error, "error"); alertify.notify(error, "error");
@ -191,7 +192,7 @@ function handle_ajax_return(
alertify.notify(success_message, "success", 5); alertify.notify(success_message, "success", 5);
return true; return true;
} }
if (!(data.errors && data.errors.length)) if (!(data.errors && data.errors.length) && !data.error)
alertify.notify( alertify.notify(
default_error ?? default_error ??
_( _(