$ deferreds

illustrating deferred

by nickkell

JavaScript

$.when($.ajax({
    type: 'POST',
    url: '/echo/json/',
    data: {
        json: JSON.stringify({
            message: 'hey'
        })
    }
}), $.ajax({
    type: 'POST',
    url: '/echo/json/',
    data: {
        json: JSON.stringify({
            message: 'goodbye'
        })
    }
})).done(function(a,b) {
    console.log(a,b);
});