Use jQuery's deferreds in a sequential way.