jQuery Deferred promise() Method

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Read-only API

What You’ll Learn

The promise() method returns a read-only view of a jQuery Deferred. Consumers can listen with then(), done(), or catch() — but cannot call resolve() or reject(). This tutorial covers syntax, encapsulation patterns, five examples, and comparisons with full Deferred objects.

01

Syntax

dfd.promise()

02

Read-only

No resolve/reject

03

Return

From async APIs

04

target

Optional object

05

vs Deferred

Hide control

06

Since 1.5

Core Deferred API

Introduction

When you build an async helper — fetch user data, run a animation sequence, wrap a timer — you usually create a $.Deferred() internally. But returning the raw Deferred gives callers the power to call resolve() or reject() themselves, which breaks encapsulation.

promise() solves that. Return deferred.promise() instead: outsiders get a thenable they can observe, while only your module settles the real Deferred.

Understanding the promise() Method

promise() creates (or augments) a promise object linked to the same underlying state as the Deferred. It exposes listener methods — done, fail, always, then, catch, progress, and state — but omits settlement methods like resolve, reject, and notify.

This is the same pattern $.ajax() uses: the jqXHR object you chain .done() onto is promise-like, while jQuery internally controls when the request completes.

💡
Beginner Tip

The reference example correctly returns deferred.promise() from fetchData() and consumes it with then() / catch(). Always settle the internal Deferred inside your module — never expect callers to resolve it for you.

📝 Syntax

General form of deferred.promise:

jQuery
deferred.promise( [ target ] )

Parameters

  • target (optional) — object onto which promise methods are copied. If omitted, jQuery returns a new plain object with those methods.

Return value

  • A promise object (or the target object) that reflects the Deferred’s state but cannot change it.

Typical async function pattern

jQuery
function fetchData() {
  const deferred = $.Deferred();

  setTimeout(function () {
    deferred.resolve({ data: "Sample data" });
  }, 500);

  return deferred.promise();
}

fetchData().then(function (response) {
  console.log("Data fetched:", response.data);
}).catch(function (error) {
  console.error("Error:", error);
});

⚡ Quick Reference

GoalCode
Return read-only promisereturn dfd.promise()
Attach to existing objectdfd.promise(widget)
Listen for successpromise.done(fn)
Promise-style chainpromise.then(fn).catch(fn)
Full control (internal only)Keep $.Deferred() private

📋 promise() vs Full Deferred

Same async outcome — different level of control exposed to callers.

promise()
listen only

done, then, fail

Deferred
full control

resolve, reject

Return from API
promise()

Encapsulation

jqXHR
$.ajax()

Built-in pattern

Examples Gallery

Each example shows how promise() exposes async results safely. Use the Try-it links to run them interactively.

📚 Getting Started

Return a promise from an async helper and consume it with then().

Example 1 — fetchData() Pattern

Internal Deferred resolves after a delay; callers receive only the promise.

jQuery
function fetchData() {
  const deferred = $.Deferred();

  setTimeout(function () {
    deferred.resolve({ data: "Sample data" });
  }, 500);

  return deferred.promise();
}

const promise = fetchData();

promise.then(function (response) {
  console.log("Data fetched:", response.data);
});
Try It Yourself

How It Works

fetchData() owns the Deferred and decides when to resolve. Callers get a promise they can observe but not settle.

Example 2 — Promise Is Read-Only

The returned promise has listener methods — not resolve or reject.

jQuery
const dfd = $.Deferred();
const promise = dfd.promise();

console.log(typeof promise.done);     // "function"
console.log(typeof promise.resolve);  // "undefined"

dfd.resolve("Settled internally");
promise.done(function (value) {
  console.log("Got:", value);
});
Try It Yourself

How It Works

Only the original dfd can call resolve(). The promise is a safe handle for external code.

📈 Practical Patterns

Target objects, shared promises, and error handling.

Example 3 — promise( target )

Attach promise methods to an existing API object.

jQuery
const dfd = $.Deferred();

const loader = {
  label: "DataLoader",
  start: function () {
    setTimeout(function () {
      dfd.resolve({ items: [1, 2, 3] });
    }, 400);
    return dfd.promise(this);
  }
};

loader.start().done(function (result) {
  console.log(loader.label + ":", result.items.length, "items");
});
Try It Yourself

How It Works

promise(this) returns the same loader object with done, then, etc. added — useful for fluent APIs.

Example 4 — Multiple Listeners on One Promise

Several modules attach handlers to the same returned promise.

jQuery
function loadConfig() {
  const dfd = $.Deferred();
  setTimeout(function () {
    dfd.resolve({ theme: "dark", lang: "en" });
  }, 300);
  return dfd.promise();
}

const configPromise = loadConfig();

configPromise.done(function (cfg) {
  console.log("UI theme:", cfg.theme);
});

configPromise.done(function (cfg) {
  console.log("Locale:", cfg.lang);
});
Try It Yourself

How It Works

One promise, many observers — same as sharing a jqXHR from $.ajax() across components.

Example 5 — Error Handling with catch()

Reject the internal Deferred; consumers handle failure on the promise.

jQuery
function fetchData(fail) {
  const deferred = $.Deferred();

  setTimeout(function () {
    if (fail) {
      deferred.reject("Network error");
    } else {
      deferred.resolve({ data: "OK" });
    }
  }, 400);

  return deferred.promise();
}

fetchData(true).then(function (r) {
  console.log(r.data);
}).catch(function (err) {
  console.error("Error fetching data:", err);
});
Try It Yourself

How It Works

Internal code calls reject(); the promise surface lets callers use catch() just like the reference example.

🚀 Use Cases

  • Public async APIs — return promise() from module functions so callers cannot force settlement.
  • AJAX wrappers — mirror $.ajax() by exposing jqXHR-style promise objects.
  • Plugin interfaces — use promise(target) on a plugin instance for chainable async methods.
  • Shared resources — pass one promise to multiple components waiting on the same load.
  • Animation helpers — wrap .fadeOut() or custom timers and return a promise for sequencing.

🧠 How promise() Encapsulates Async Work

1

Create

Module creates private $.Deferred() and starts async work.

Internal
2

Expose

Return dfd.promise() — read-only handle for callers.

Public
3

Settle

Module calls resolve() or reject() when work finishes.

Owner
=

Safe boundary

Callers listen; only the owner controls the outcome.

📝 Notes

  • Always return promise() from public APIs — keep the Deferred variable private.
  • Calling promise() multiple times on the same Deferred returns equivalent thenables tied to the same state.
  • jQuery 3+ promises support then() / catch() like native Promises.
  • promise() does not clone async work — it only restricts the interface.
  • For combining multiple promises, use $.when() with promise objects.

Browser Support

deferred.promise() 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.promise()

Universal wherever jQuery Deferred runs. jQuery 3+ promise objects are Promises/A+ compatible via then().

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.promise() Universal

Bottom line: Standard pattern for encapsulating jQuery async APIs since 1.5. $.ajax() jqXHR objects follow the same model.

🎉 Conclusion

The deferred.promise() method exposes a read-only view of async work. Return it from your functions, settle the internal Deferred yourself, and let consumers chain then() or done() safely.

Next, explore reject() to see how Deferred owners signal failure — the counterpart to resolve().

💡 Best Practices

✅ Do

  • Return dfd.promise() from public async functions
  • Keep the Deferred variable module-private
  • Chain catch() or fail() on consumed promises
  • Use promise(target) for fluent plugin APIs
  • Document what values resolve/reject carries

❌ Don’t

  • Return raw Deferred objects to external callers
  • Expect consumers to call resolve() for you
  • Leak internal Deferred references globally
  • Forget error handlers on returned promises
  • Confuse promise() with creating a native Promise constructor

Key Takeaways

Knowledge Unlocked

Five things to remember about promise()

How to expose async results safely in jQuery.

5
Core concepts
🔒 02

No settle

Listen only

Safe
📦 03

target

Attach methods

Optional
🔗 04

Share

Many listeners

Pattern
ajax 05

jqXHR

Same idea

Real world

❓ Frequently Asked Questions

promise() returns a promise object tied to the same async outcome as the Deferred. Callers can attach done(), fail(), then(), or catch() — but they cannot call resolve(), reject(), or notify() on the returned object.
To encapsulate control. Only the code that created the Deferred should settle it. Returning promise() exposes status listeners without letting outside code force resolve or reject.
promise(target) copies promise methods (done, fail, then, etc.) onto an existing object and returns that object. Useful when a widget or API object should be both a DOM helper and thenable.
No. The read-only promise does not expose resolve, reject, or notify. Only the original Deferred owner can settle the operation.
Similar in purpose — both represent a future result — but jQuery's promise is thenable and supports done/fail/progress. jQuery 3+ Deferreds are Promises/A+ compatible via then().
Yes. jqXHR objects are promise-like and support .done(), .fail(), .always(), and .then(). Internally they use the same Deferred machinery as deferred.promise().
Did you know?

Before ES2015 native Promises, jQuery’s deferred.promise() was many developers’ first introduction to “return a thenable, keep settlement private.” The same encapsulation idea now appears in fetch, async/await, and the Promise constructor.

Continue to reject()

Learn how Deferred owners signal failure to promise consumers.

reject() 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