jQuery Deferred promise() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Deferred

Definition

deferred.promise() returns a Promise for that Deferred (since jQuery 1.5). The Promise lets other code attach handlers or read state(), but it hides methods that change the outcome — resolve, reject, notify, and their *With forms.

Syntax

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

jQuery
deferred.promise([target])

Promise has:  then, done, fail, always, progress, state, pipe, promise
Promise lacks: resolve, reject, notify (+ *With)

Pattern:
  keep Deferred private
  return dfd.promise() to callers
CallWhat it does
targetObject that receives promise methods; returned instead of a new Promise
ReturnPromise (or the target with promise methods attached)
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 inside your async function.
Step 2Start the work; call resolve / reject / notify only there.
Step 3Return dfd.promise() (or dfd.promise(target)).

Return Value

Return ValueDescription
See examplesCheck the examples below for what this API returns in common cases.

jQuery Examples

Example 1 — Return promise() from a Helper

Create a Deferred inside the function; give callers only the Promise.

jQuery
function fetchData() {
  var dfd = $.Deferred();
  setTimeout(function () {
    dfd.resolve({ data: "Sample data" });
  }, 200);
  return dfd.promise();
}

fetchData().done(function (response) {
  console.log(response.data);  // Sample data
});
Try It Yourself

How It Works

  1. Private Deferred. dfd lives only inside fetchData.
  2. Resolve later. The timeout settles success with an object.
  3. Return Promise. Callers get promise(), not dfd.

Example 2 — Promise Hides resolve

Compare methods on the Deferred versus the Promise.

jQuery
var dfd = $.Deferred();
var p = dfd.promise();

console.log(typeof dfd.resolve);  // "function"
console.log(typeof p.resolve);    // "undefined"
console.log(typeof p.done);       // "function"
Try It Yourself

How It Works

  1. Full Deferred. dfd.resolve exists so the owner can settle.
  2. Promise view. p.resolve is missing — callers cannot force success.
  3. Listeners remain. p.done is still a function.

Example 3 — done and fail on the Promise

Attach success and failure handlers to the returned Promise.

jQuery
function loadUser(ok) {
  var dfd = $.Deferred();
  setTimeout(function () {
    if (ok) dfd.resolve("Alex");
    else dfd.reject("offline");
  }, 200);
  return dfd.promise();
}

loadUser(true).done(function (name) {
  console.log("Hi", name);   // Hi Alex
}).fail(function (err) {
  console.log("Err", err);
});
Try It Yourself

How It Works

  1. Helper owns settle. ok chooses resolve or reject inside the timeout.
  2. Return Promise. The caller never sees dfd.
  3. Chain done/fail. Success prints Hi Alex.

Frequently Asked Questions

promise() returns a Promise tied to the same outcome as the Deferred. Callers can use then, done, fail, always, progress, state, pipe, and promise — but not resolve, reject, notify, or the *With variants.
Encapsulation. Only the owner should settle the operation. Returning promise() lets other code attach handlers or inspect state without forcing resolve, reject, or notify.
promise(target) attaches promise methods onto an existing object and returns that object. Useful when an API object should also act as a thenable Promise.
No. The Promise does not expose resolve, reject, or notify. Only the original Deferred can settle the work.
Similar idea — a future result — but jQuery’s Promise also supports done/fail/progress. In jQuery 3+, then() follows Promises/A+ semantics.
No. Each promise() view observes the same Deferred. Settling the Deferred once settles every promise derived from it.

Next: deferred.isResolved() Method

Learn how the Deferred owner marks a Promise as failed.

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