Skip to content

Commit d97aefa

Browse files
committed
ACP2E-1369: clear previous error message if ajax request completed on subsequent try
1 parent ff2bff1 commit d97aefa

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

lib/web/mage/backend/bootstrap.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ define([
6262

6363
if (jqXHR.readyState === 4) {
6464
try {
65-
$('body').notification('clearCallbackError');
6665
jsonObject = JSON.parse(jqXHR.responseText);
66+
6767
if (jsonObject.ajaxExpired && jsonObject.ajaxRedirect) { //eslint-disable-line max-depth
6868
window.location.replace(jsonObject.ajaxRedirect);
6969
}
@@ -73,10 +73,15 @@ define([
7373

7474
/**
7575
* Error callback.
76+
*
77+
* @param {Object} jqXHR - The jQuery XMLHttpRequest object returned by $.ajax()
78+
* @param {String} textStatus
7679
*/
77-
error: function () {
78-
$('body').notification('clear')
79-
.notification('add', {
80+
error: function (jqXHR, textStatus) {
81+
82+
$('body').notification('clear');
83+
if (jqXHR.readyState !== 0 && textStatus !== 'abort') {
84+
$('body').notification('add', {
8085
error: true,
8186
message: $.mage.__(
8287
'A technical problem with the server created an error. ' +
@@ -87,11 +92,12 @@ define([
8792
* @param {String} message
8893
*/
8994
insertMethod: function (message) {
90-
var $wrapper = $('<div class="callback"></div>').html(message);
95+
var $wrapper = $('<div></div>').html(message);
9196

9297
$('.page-main-actions').after($wrapper);
9398
}
9499
});
100+
}
95101
}
96102
});
97103

lib/web/mage/backend/notification.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ define([
7777
*/
7878
clear: function () {
7979
$(this.placeholder).html('');
80-
},
81-
82-
/**
83-
* Remove generic callback error message
84-
*/
85-
clearCallbackError: function () {
86-
$('body').find('.callback .messages .message-error').parent().html('');
8780
}
8881
});
8982

0 commit comments

Comments
 (0)