jQuery Deferred resolve() Method

Beginner
7 min read
Updated: Oct 2026
5 examples
Live preview

What Is resolve()?

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.

Remember
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
NeedUse
Signal successdfd.resolve(value)
Listen for successdfd.done(fn)
Custom this + args arraydfd.resolveWith(ctx, args)

How to Use resolve()

Own the Deferred; resolve when the work succeeds; let others listen.

  1. Create a Deferred (keep it private in your helper).
  2. Attach done() / then() (or return promise() for callers).
  3. On success, call resolve(args…) with useful results.
  4. Do not call reject() afterward — the Deferred is already settled.
PieceRequired?Role
argsOptionalValues passed to every done callback
Return—Same Deferred (chainable)
Since—jQuery 1.5

Pseudocode

Pseudocode
dfd = Deferred
handlers = done callbacks (from done / then)

resolve(args…):
    if dfd already settled: return  // ignore
    state = "resolved"
    remember args
    for each done handler (in add order):
        handler(args…)

later done(fn):
    if already resolved: fn(args…) immediately
    else: queue fn

Cheat Sheet

Keep these facts handy when signaling async success.

TopicDetail
Syntaxdeferred.resolve([args…])
Triggersdone(), success branch of then(), always()
State"resolved" — settles once
Late done()Runs immediately with the resolve args
vs done()resolve fires; done listens
vs reject()Success vs failure settlement
SincejQuery 1.5

Live Preview

See how resolve() drives done() and once-only settlement.

Browser demo of deferred.resolve — same idea as the examples below.

Result
done → Operation complete
state → resolved

/* resolve() settles; done() listens */

jQuery Examples

Short, copy-ready snippets. Open the browser console, or use Try It Yourself for a live editor.

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.
  4. State locks. The Deferred is now "resolved".

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.
  4. Keep it consistent. Use the same arg order everywhere you resolve.

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".
  4. Useful for UI. Late listeners still see the final result.

Example 4 — Settle Once (Resolve After Reject Ignored)

After reject(), a later resolve() does nothing.

jQuery
var dfd = $.Deferred();
var lines = [];

dfd.done(function (v) { lines.push("done: " + v); });
dfd.fail(function (v) { lines.push("fail: " + v); });

dfd.reject("nope");
dfd.resolve("ok");  // ignored

console.log(lines.join(" | "));  // fail: nope
console.log(dfd.state());         // rejected
Try It Yourself

How It Works

  1. Attach both paths. done and fail are ready.
  2. Reject first. State becomes "rejected"; fail runs.
  3. Resolve later. Ignored — done never runs.
  4. Rule. First settle wins; the other is a no-op.

Example 5 — Resolve Behind promise()

Only the owner resolves; callers listen on the returned Promise.

jQuery
function loadFile(ok) {
  var dfd = $.Deferred();
  setTimeout(function () {
    if (ok) dfd.resolve("file.txt");
    else dfd.reject("missing file");
  }, 200);
  return dfd.promise();
}

loadFile(true).done(function (name) {
  console.log(name);  // file.txt
});
Try It Yourself

How It Works

  1. Private Deferred. Only loadFile can call resolve.
  2. Return Promise. Callers get promise(), not settle methods.
  3. Success path. ok is true → resolve("file.txt").
  4. Listen outside. done on the Promise prints the name.

Edge Cases & Pitfalls

Check these before relying on resolve() in real projects.

once

Settles only once

After resolve or reject, further settle calls are ignored. Check state() if you need to know which won.

owner

Only the owner should resolve

Official guidance: return promise() so other code cannot change state with resolve().

args

Pass useful result data

Empty resolve() works but often forces handlers to look elsewhere for data. Prefer the actual payload.

context

Need a custom this?

Use resolveWith(context, args) when done handlers rely on a specific this.

Browser Support

deferred.resolve() needs jQuery 1.5+ loaded. It works across jQuery 1.5–3.x as the standard way to settle a Deferred as successful.

✓ jQuery 1.5+

deferred.resolve()

Works in Chrome, Firefox, Safari, and Edge when jQuery 1.5+ is loaded. Pair with done() or then() to handle the result.

100% With jQuery 1.5+
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
resolve() Universal

Bottom line: Safe wherever jQuery Deferreds exist. Keep resolve() private; expose promise() to callers.

Performance Notes

ApproachCostBest for
resolve(args)O(handlers)Normal success settlement
Many done handlersEach runs onceKeep handlers small
Resolve after settleNo-opHarmless but wasteful — avoid

Resolution cost is dominated by your done handlers (DOM updates, routing), not by resolve() itself. Pass compact results unless a large payload is required.

Key Takeaways

  • Role: settle a Deferred as successful and run done callbacks.
  • Pair: resolve fires; done / then listen.
  • Once: after settle, later resolve/reject are ignored.
  • Safety: return promise() so callers cannot resolve.

One line: resolve(args) marks success — keep it private, pass clear results, listen with 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()

Resolve with a custom this context and an arguments array.

resolveWith() tutorial →

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