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:
Ingo Schommer 2012-05-10 10:44:21 +02:00
parent 6956b1be5c
commit 2753744f9e

View File

@ -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.
*