The done() method registers a success callback on a jQuery Deferred. It runs when the operation resolves — with data from resolve(), an AJAX response, or a completed animation. This tutorial covers syntax, five examples, comparisons with fail() and then(), and best practices.
01
Syntax
dfd.done(fn)
02
On resolve
Success only
03
vs fail()
Error path separate
04
AJAX
$.ajax().done()
05
Multiple
Queue handlers
06
Since 1.5
Core Deferred API
Fundamentals
Introduction
Async tasks usually end in one of two ways: success or failure. jQuery’s done() method is dedicated to the success path. When a Deferred resolves — because an AJAX call returned data, a timer finished, or you called resolve() manually — every registered done() callback runs with the result.
Keep outcome-specific work in done(): render UI, parse JSON, trigger follow-up requests. Pair it with fail() or catch() for errors and always() for shared cleanup.
Concept
Understanding the done() Method
done() is part of jQuery’s Deferred Object API (since jQuery 1.5). Calling deferred.done(callback) adds your function to a success queue. When the Deferred enters the resolved state, jQuery invokes each callback in order, passing the values from resolve().
done() does not run on rejection. If the Deferred fails, only fail(), catch(), and always() handlers execute (plus then() rejection branches).
💡
Beginner Tip
If you register done() after the Deferred already resolved, jQuery still calls your handler immediately — handy when different modules attach listeners at different times.
Foundation
📝 Syntax
General form of deferred.done:
jQuery
deferred.done( doneCallback [, doneCallback ] )
Parameters
doneCallback — function executed when the Deferred resolves. Receives resolve arguments (often one data object, or multiple values from resolve(a, b, c)).
Return value
Returns the same Deferred object for chaining fail(), always(), or another done().
jQuery calls every done() handler in registration order with the same resolve arguments — similar to adding multiple event listeners for one success signal.
Example 4 — Multiple Resolve Arguments
resolve() can pass several values; done() receives them as separate parameters.
deferred.done() has been available since jQuery 1.5 alongside the Deferred API. It works in every browser your jQuery build supports.
✓ jQuery 1.5+
jQuery Deferred.done()
Supported in jQuery 1.5+, 2.x, and 3.x. Behavior is consistent across browsers because jQuery implements the callback queue internally.
100%With jQuery loaded
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
deferred.done()Universal
Bottom line: Safe in any project using jQuery Deferred or jqXHR. For greenfield code without jQuery, native Promise .then() is the modern equivalent for success handlers.
Wrap Up
🎉 Conclusion
The deferred.done() method is jQuery’s dedicated success handler. Register callbacks before or after resolve(), process AJAX responses, and split work across multiple focused listeners — then pair with fail() for a complete async story.
Practice the five examples above, then continue to fail() to handle the rejection path on the same Deferred chain.
Return transformed values expecting chain updates — use then()
Trust server data without validation
Forget late listeners — they still run after resolve
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about done()
Your success path for jQuery async work.
5
Core concepts
📝01
Syntax
dfd.done(fn)
API
✅02
Resolve
Success only
Trigger
🔗03
Queue
Multiple fns
Order
📦04
Args
From resolve()
Data
⏰05
Late fn
Still runs
Tip
❓ Frequently Asked Questions
done() registers a callback that runs when the Deferred is resolved (success). The handler receives whatever values were passed to resolve() or resolveWith().
done() runs only on resolve. fail() runs only on reject. They are mutually exclusive for a given settlement — pair done() with fail() or catch() to cover both outcomes.
Similar for success: then(onFulfilled) runs when resolved. done() is jQuery's legacy name and only handles success — it does not accept a rejection handler. then() accepts both fulfilled and rejected callbacks (jQuery 3+).
Yes. Each done callback is queued and executed in registration order when the Deferred resolves.
Yes. If the Deferred is already resolved, new done() handlers fire immediately with the resolved values.
Yes. jqXHR objects support .done(), .fail(), and .always() — a common pattern for processing successful HTTP responses.
Did you know?
Before jQuery unified callbacks with Deferred in 1.5, $.ajax() used separate success, error, and complete options. done(), fail(), and always() replaced that pattern with chainable methods on the same object.