jQuery Deferred resolve() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Deferred

Definition

deferred.resolve([args]) settles a Deferred as resolved (since jQuery 1.5) and runs done callbacks from done() or then(). Optional args are passed to those handlers. It returns the same Deferred for chaining.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
deferred.resolve([args…])

resolve()  → settle as success (owner only)
done()     → listen for success
reject()   → settle as failure (opposite)

state locks after resolve — once only
return promise() so callers cannot resolve
CallWhat it does
argsValues passed to every done callback
ReturnSame Deferred (chainable)
SincejQuery 1.5

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Create a Deferred (keep it private in your helper).
Step 2Attach done() / then() (or return promise() for callers).
Step 3On success, call resolve(args…) with useful results.

Return Value

Return ValueDescription
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

Example 1 — resolve() + done()

Settle as successful and read the result in a done handler.

jQuery
var dfd = $.Deferred();

dfd.done(function (result) {
  console.log(result);  // Operation complete
});

dfd.resolve("Operation complete");
Try It Yourself

How It Works

  1. Register done. The handler waits for success.
  2. Call resolve. Pass a clear result value.
  3. Handler runs. It receives that same value.

Example 2 — Multiple Resolve Arguments

Pass several values; every done callback receives them in order.

jQuery
var dfd = $.Deferred();

dfd.done(function (id, name) {
  console.log(id + ": " + name);  // 42: Alex
});

dfd.resolve(42, "Alex");
Try It Yourself

How It Works

  1. Plan the shape. Done handlers expect (id, name).
  2. Resolve with two args. resolve(42, "Alex").
  3. Receive both. The callback logs them together.

Example 3 — Late done() After Resolve

Handlers added after resolution run immediately with the resolve args.

jQuery
var dfd = $.Deferred();

dfd.resolve("already done");

dfd.done(function (result) {
  console.log(result);  // already done
});
Try It Yourself

How It Works

  1. Resolve first. State becomes resolved; args are stored.
  2. Attach done late. Official rule: it runs immediately.
  3. Same args. You still get "already done".

Frequently Asked Questions

resolve() settles the Deferred as successful and runs doneCallbacks from done() or then(). Optional args are passed to those handlers. The state becomes resolved and stays locked.
resolve() is called by the Deferred owner to signal success. done() registers a listener that runs when resolution happens. resolve fires; done listens.
No. A Deferred settles once. After reject(), later resolve() is ignored. After resolve(), later reject() is ignored.
Any values — a string, object, array, or multiple arguments. Each done callback receives the same args from the resolve() call.
Late done() handlers run immediately with the arguments that were passed to resolve() — same idea as late fail() after reject().
Usually no. Keep the Deferred private and return promise() so outside code can attach done/fail but cannot settle the operation.

Next: deferred.resolveWith() Method

Resolve with a custom this context and an arguments array.

deferred.resolveWith() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful