I am running jQuery version 1.10.X( Yes! I am a little slow! ) and facing this weird issue where doneFilter
and failFilter
passed inside .then()
do not work if I have a success
block in the ajax call.
This, however, seems to me like an issue with my own codebase. Proof(..or maybe not..)? I tried a simple example. Things work in the example and as I would expect, the success
and doneFilter
have been queued and executed.
Now in my codebase, which is absolutely similar as the example above, the .then()
part does not execute if I have a success
block which is strange. Removing the success block enables .then()
and the doneFilter
/ failFilter
gets executed.
Strangely, In my same codebase, they both play nice if I have jQuery - 1.7.X. Could it be an issue because of the changes the ajax framework has gone through in 1.8 and above?
If not, any hints about how to figure out what the issue is? I have checked the methods used as doneFilter
and failFilter
. No syntax errors. They are merely anon. functions containing console statements.
CODE :
function getMonster (){
var theMonster = $.ajax({
url : "http://codepen.io/chriscoyier/pen/difoC.html",
success : function(data){
console.log("Monster Succeeded inside 'success' block");
}
});
return theMonster;
}
var theMonster = getMonster();
theMonster.then (function(){
console.log("Moster Succeeded outside");
}, function(){
console.log("Monster Failed :(");
});
EDIT :
I am doing an ajaxSetup
as follows.
$.ajaxSetup({
beforeSend: function(jqXHR) {
if ($.cookie("mycookie") == null) {
console.info("Expired Session");
AppModule.timeout();
return false;
}
}
});
EDIT 2 : Has anyone ever faced an issue like this before or am I the only one seeing the monster fail? There's not a single exception thrown which is making it even harder to find out what is wrong.