Asynchronous JavaScript - Callbacks vs Deferred/Promise [duplicate]

Promises also rely on callbacks behind the scene, so it's not really one vs. the other.

The benefit of callbacks is that they are easy to implement with plain JavaScript (for example in ajax calls).

Promises require an additional abstraction layer, which usually means that you'll rely on a library (not an issue in your case as you are already using jQuery). They are perfect when you deal with multiple async calls in parallel.


From reading the jQuery docs that @Pointy linked to, it sounds like the difference is that the Deferred API allows you to specify more than one function to be called when your request completes:

As of jQuery 1.5, the error (fail), success (done), and complete (always, as of jQuery 1.6) callback hooks are first-in, first-out managed queues. This means you can assign more than one callback for each hook. See Deferred object methods, which are implemented internally for these $.ajax() callback hooks.

See also: deferred.then()