$.get('/ajax/1/').done(function(){
console.log('ajax 1 success'); // first ajax scope
})
.then(function(){
return $.get('/ajax/2/'); // but if we're returning promise ...
})
.done(function(){
console.log('ajax 2 success'); // ... scope changes
})
$.get('/ajax/1/')
.done(...)
.fail(...)
.when(
function(){
return $.get('/ajax/2/');
},
function(){
var d = $.Deferred();
$('#id').fadeOut(d.resolve);
return d.promise();
}
)
.done(...)
.fail(...)