I saw this code at the jQuery site :
1: var jqxhr = $.ajax( "example.php" )
.done(function() { alert("success"); })
.fail(function() { alert("error"); })
.always(function() { alert("complete"); });
2: // perform other work here ...
// Set another completion function for the request above
3: jqxhr.always(function() { alert("second complete"); });
2 questions :
I heard that the callback functions arguments of
success,error,completebeing transferred todone,fail,alwaysrespectively.
So if I want to use the jqXHR obj in always callback , How can i know from where he came (
errororsuccess) - because theparams orderin the method signature is different !!!//here it is at place 3

//here it is at place 1

I also heard that deferred objects help us to build the callback functions dynamically. (as we can see in '
3:')I don't understand why will I ever need it ? by the time I got the Section
3:- the ajax call has already been made and alerted completed. In what scenarios the section3:comes into action?
complete()is not meant to perform operations where it matters if the request was successful or not but to perform generic actions such as cleaning up things, re-enabling a disabled button, etc.