I have the following code and I would like to be able to abort the event handling:
var req = $.get(myurl).done(function() {
console.log('error!!! abort event handling!');
req.abort();
}).done(function() {
console.log('success!');
}).done(function() {
console.log('success again!');
}).done(function() {
console.log('and again!');
});
but even when I explicitly aborted the request ( req.abort() ), the rest of the callback functions are still being executed. I don't want the rest of the callback functions to be called. How could I achieve this?
I created my own post function. It is basically an extension of the ajax post function:
function custompost(args) {
var onDone = function () {
if (!specialcondition) {
console.log('an error has occurred!!! abort! abort!');
}
}
var req = $.post.apply(this, Array.prototype.slice.call(arguments));
req.done(onDone);
return req;
}
The problem is the following. When I call my function:
custompost(url, data, onSuccess);
var onsuccess = function() {
console.log('success');
}
the 'onSuccess' function is called before than the 'onDone' function. How can I change the order of execution and avoid the 'onSuccess' function to be called?