Returning a deferred object from a deferred objects callback?
I´m desperate! I have asked around but couldn´t get any help. This is what i am trying to do:
http://jsfiddle.net/Rm9KR/
Note that:
document.write(d.state()+"<br>");
d.then(function(){
document.write(d.state()+"<br>");
},function(){
document.write(d.state()+"<br>");
});
Will never run. since i try this from the function:
error: function(data,status)
{
document.write('ajax done: fail');
dfd.reject();
return dfd;
}
I try to tell the caller that the Ajax call failed (or succeded). I know i can just:
return ajax()
But in my example above is not my real world function. It is more complex and nested with other ajax calls that will together make a success or fail.
Hope i can get some help here. I´m frustrated!
Thanx in advance!