JSFiddle - React, Tailwind, and code Playground
JavaScript
var xhr, uuid = 0;
function success(data, status, xhr) {
$('body').append('<div>success: ' + xhr._uuid + '</div>');
};
function badSuccess(data, status, xhr) {
$('body').append('<div>badSuccess: ' + xhr._uuid + '</div>');
throw new Error('I hate life!');
};
function error(xhr, status, error) {
$('body').append('<div>error: ' + xhr._uuid + '</div>');
};
function badError(xhr, status, error) {
$('body').append('<div>badError: ' + xhr._uuid + '</div>');
throw new Error('It’s so just error!');
};
function complete(xhr, status) {
$('body').append('<div>complete: ' + xhr._uuid + '</div>');
}
xhr = $.ajax({
url: '/ajax_json_echo/',
error: error,
complete: complete,
success: success
});
xhr._uuid = uuid++;
xhr = $.ajax({
url: '/ajax_json_echo/',
error: error,
complete: complete,
success: badSuccess
});
xhr._uuid = uuid++;
xhr = $.ajax({
url: '/this_is_a_404/',
error: error,
complete: complete,
success: success
});
xhr._uuid = uuid++;
xhr = $.ajax({
url: '/this_is_a_404/',
error: badError,
complete: complete,
success: success
});
xhr._uuid = uuid++;