jQuery Deferred resolve() Method

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Settle as success

What You’ll Learn

The resolve() method marks a jQuery Deferred as successful. It runs done() and then() handlers with your result value — and prevents fail() from firing. This tutorial covers syntax, five examples, comparisons with reject() and done(), and when to resolve vs reject.

01

Syntax

dfd.resolve(value)

02

State

resolved

03

done()

Handlers run

04

vs reject

One settlement

05

Owner only

Not on promise

06

Since 1.5

Core Deferred API

Introduction

Async work eventually finishes — data loads, validation passes, animations complete. When you own a $.Deferred(), you signal success by calling resolve() — the mirror image of reject() for failure.

Listeners registered with done() or then() receive the result you pass. Consumers holding only a promise() cannot call resolve() — only the module that created the Deferred settles it.

Understanding the resolve() Method

resolve() transitions a pending Deferred into the resolved state. jQuery invokes every queued done(), then(), and success branch of always() handlers with the arguments you pass to resolve().

Once resolved, the state is permanent — you cannot reject() the same Deferred afterward. fail() handlers never run on a resolved Deferred.

💡
Beginner Tip

Register done() before calling resolve() when teaching or debugging — the flow is easier to follow. jQuery still runs handlers added after resolution, but attaching first keeps examples clear.

📝 Syntax

General form of deferred.resolve:

jQuery
deferred.resolve( [ args ] )

Parameters

  • args (optional) — result value(s) forwarded to done() handlers: string, object, array, or multiple values.

Return value

  • Returns the same Deferred object for chaining (though state is now locked to resolved).

Basic resolve + done handler

jQuery
const dfd = $.Deferred();

dfd.done(function (message) {
  console.log("Success:", message);
});

dfd.resolve("Data successfully loaded");

⚡ Quick Reference

GoalCode
Mark as successfuldfd.resolve(result)
Listen for successdfd.done(fn)
Mark as faileddfd.reject(reason)
Either outcome cleanupdfd.always(fn)
Resolve with custom thisdfd.resolveWith(ctx, [result])

📋 resolve() vs done() vs reject()

Settle success, listen for success, or settle failure — three distinct roles.

resolve()
settle OK

Owner signals success

done()
listen

Callback on resolve

reject()
settle fail

Opposite outcome

Once
locked

One settlement only

Examples Gallery

Each example shows a common resolve() pattern. Use the Try-it links to run them interactively.

📚 Getting Started

Resolve after simulated async work and handle the result in done().

Example 1 — Async Data Load

Register done(), simulate loading with setTimeout, then resolve with a message.

jQuery
const dfd = $.Deferred();

dfd.done(function (message) {
  console.log(message);
});

setTimeout(function () {
  dfd.resolve("Data successfully loaded");
}, 500);
Try It Yourself

How It Works

While pending, the Deferred waits. When the timer fires, resolve() settles and every done() handler runs with the message.

Example 2 — Conditional Resolve (Async Check)

After async work, resolve when a condition passes — otherwise reject.

jQuery
const dfd = $.Deferred();

dfd.done(function (message) {
  console.log("Success:", message);
}).fail(function (error) {
  console.error("Error:", error);
});

setTimeout(function () {
  const conditionMet = true;

  if (conditionMet) {
    dfd.resolve("Operation completed successfully.");
  } else {
    dfd.reject("Operation failed: Condition not met.");
  }
}, 500);
Try It Yourself

How It Works

Handlers attach first; the timer picks exactly one path. Success skips fail() entirely.

📈 Practical Patterns

Mutual exclusion with reject, rich result payloads, and encapsulated APIs.

Example 3 — resolve() vs reject()

A Deferred settles once — success and failure are mutually exclusive.

jQuery
function settle(ok) {
  const dfd = $.Deferred();

  dfd.done(function (v) { console.log("resolved:", v); });
  dfd.fail(function (e) { console.log("rejected:", e); });

  if (ok) {
    dfd.resolve("OK");
    dfd.reject("Too late");  // ignored — already resolved
  } else {
    dfd.reject("Failed");
    dfd.resolve("Too late"); // ignored — already rejected
  }
}

settle(true);  // resolved: OK
Try It Yourself

How It Works

The second settlement call is ignored. Always pick exactly one: resolve() or reject().

Example 4 — Multiple Resolution Arguments

Pass status, body, and metadata — done() receives them as separate parameters.

jQuery
const dfd = $.Deferred();

dfd.done(function (status, body, meta) {
  console.log(status, body.label, meta.cached);
});

dfd.resolve(200, { label: "Users" }, { cached: true });
Try It Yourself

How It Works

Same multi-argument pattern as reject() — useful for HTTP-style success tuples in custom async helpers.

Example 5 — Resolve Inside a promise() API

Module resolves internally; callers handle success on the returned promise.

jQuery
function saveUser(name) {
  const dfd = $.Deferred();

  if (!name || name.length < 2) {
    dfd.reject("Name must be at least 2 characters");
  } else {
    dfd.resolve({ saved: true, name: name });
  }

  return dfd.promise();
}

saveUser("Alex").done(function (result) {
  console.log("Saved:", result.name);
});
Try It Yourself

How It Works

Validation passes, so the module resolves with a result object. External code only sees the read-only promise and uses done() for success.

🚀 Use Cases

  • Custom async helpers — wrap timers, workers, or third-party APIs and resolve when work completes.
  • Successful AJAX — resolve in hand-rolled Deferred wrappers when HTTP status is OK.
  • Animation completion — resolve when a CSS or jQuery animation finishes so the next step can run.
  • Data processing — resolve with computed results after parsing, filtering, or transforming data.
  • Promise chains — resolve propagates to downstream done() / then() handlers.

🧠 What Happens When You Call resolve()

1

Pending

Deferred waits; done() handlers may already be registered.

Before
2

resolve()

State locks to resolved; done/then/always handlers run.

Settle
3

No fail()

Failure handlers are skipped; further resolve/reject calls ignored.

Final
=

Handled success

UI updates via done(); cleanup via always().

📝 Notes

  • Only call resolve() on Deferreds you own — not on promises returned to you.
  • Always pair public async APIs with consumer-side done() or then().
  • Pass meaningful result values — objects, arrays, or structured tuples.
  • state() returns "resolved" after resolve (preferred over deprecated isResolved() in jQuery 3+).
  • For custom this in done handlers, use resolveWith() next.

Browser Support

deferred.resolve() has been available since jQuery 1.5 alongside the Deferred API. It works in jQuery 1.5+, 2.x, and 3.x.

jQuery 1.5+

jQuery Deferred.resolve()

Universal wherever jQuery Deferred runs. jqXHR uses the same resolution machinery when AJAX requests succeed.

100% With jQuery loaded
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
deferred.resolve() Universal

Bottom line: Core API for signaling async success in jQuery since 1.5. Always handle results on the consumer side.

🎉 Conclusion

The deferred.resolve() method settles a Deferred as successful. Call it when data is ready, validation passes, or async work completes — then let done() and then() update the UI or continue the workflow.

Next, explore resolveWith() when done handlers need a custom this context, or review done() for the listener side of success handling.

💡 Best Practices

✅ Do

  • Register done() before or when returning promises
  • Pass clear, structured result values
  • Resolve once when work is truly complete
  • Use always() for shared cleanup
  • Return promise() — resolve on the private Deferred

❌ Don’t

  • Call both resolve() and reject()
  • Resolve without any done/then handler in user flows
  • Expose resolve() on public promise objects
  • Resolve before sending final progress with notify()
  • Assume fail() runs after resolve

Key Takeaways

Knowledge Unlocked

Five things to remember about resolve()

How to signal success on a jQuery Deferred.

5
Core concepts
02

State

resolved

Success
done 03

done()

Runs on resolve

Listen
1x 04

Once

Locked state

Final
vs 05

reject

Opposite

Pair

❓ Frequently Asked Questions

resolve() settles the Deferred as successful. It triggers done(), then(), and the success branch of always() handlers, passing optional result values (data object, message, etc.). The state locks to resolved — fail() will not run.
resolve() is called by the Deferred owner to signal success. done() registers a callback that runs when resolution happens. Think: resolve() fires the event; done() listens for it.
No. A Deferred settles once. If it already rejected, a later resolve() is ignored. Likewise, reject() after resolve() has no effect.
Any value — a string, object, array, or multiple arguments like resolve(status, body, meta). done() handlers receive the same arguments.
No. Resolution triggers done/then/always success paths, not progress. Send final progress updates with notify() before resolve() if needed.
Use resolveWith(context, args) when done() handlers need a specific this value and arguments in an array — same pattern as rejectWith() and notifyWith().
Did you know?

When a jQuery AJAX request succeeds, the jqXHR object resolves its internal Deferred automatically — you handle it with .done() without calling resolve() yourself. Custom helpers that wrap non-jQuery async code use resolve() the same way jQuery does internally for successful HTTP responses.

Continue to resolveWith()

Learn how to resolve with a custom this context in done handlers.

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.

6 people found this page helpful