title: Can I access the Deferred object from within an AJAX deferred callback?
body: <p>Is there any way I can access the internal Deferred object from an ajax's success callback? I want to be able to pass abstract out an ajax call into a function, yet be able to wrap that function call in a $.when() and use reject() and resolve() to pass arguments back to my done() and fail() callbacks like so: </p>
  
  <pre><code> $.when(makeCall())
   .done(function(data){
       //do something with data
    })
   .fail(function(message){
       //show error
    });
  
   function makeCall(){
       return $.ajax({
           url : //some url,
           success : function(data){
                if(!data.someCondition){
                   //i'd like to reject the internal deferred here
                   //and send it back an error message to my
                   //the callers fail method like reject('message')
                }
                else{
                   //i'd like to resolve the deferred here and 
                   //pass back the data to the callers done
                   //method like resolve(data)
                }
           }
       });
   }
  </code></pre>
  
  <p>Right now I'm wrapping makeCall() in another Deferred object and resolving or rejecting that one in the ajax callbacks but it feels like I should be able to do this without having that extra Deffered wrapper.</p>