mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Moving X-Status message handling in CMS from global ajaxError to ajaxComplete handler, to allow success messages being passed this way as well.
This commit is contained in:
parent
6956b1be5c
commit
2753744f9e
@ -47,18 +47,19 @@ jQuery.noConflict();
|
||||
window.History.pushState(opts, '', url);
|
||||
}
|
||||
}
|
||||
});
|
||||
$(document).ajaxError(function(e, xhr, settings, error) {
|
||||
if(xhr.status == 0) return; // ignore aborted requests
|
||||
|
||||
if(xhr.status < 200 || xhr.status > 399) {
|
||||
var msg = (xhr.getResponseHeader('X-Status')) ? xhr.getResponseHeader('X-Status') : xhr.statusText;
|
||||
} else {
|
||||
msg = error;
|
||||
// Handle custom status message headers
|
||||
var msg = (xhr.getResponseHeader('X-Status')) ? xhr.getResponseHeader('X-Status') : xhr.statusText,
|
||||
msgType = (xhr.status < 200 || xhr.status > 399) ? 'bad' : 'good',
|
||||
ignoredMessages = ['OK'];
|
||||
|
||||
// Show message (but ignore aborted requests)
|
||||
if(xhr.status !== 0 && msg && $.inArray(msg, ignoredMessages)) {
|
||||
statusMessage(msg, msgType);
|
||||
}
|
||||
statusMessage(msg, 'bad');
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Main LeftAndMain interface with some control panel and an edit form.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user