jQuery Deferred isRejected() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Deferred

Definition

deferred.isRejected() was a boolean check: true after reject() / rejectWith(), otherwise false. It took no arguments. Today, use state() instead.

Syntax

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

jQuery
// OLD (jQuery 1.5–1.7 only — removed in 1.8)
dfd.isRejected()  → true | false

// MODERN replacement
dfd.state() === "rejected"

state(): "pending" | "resolved" | "rejected"
CallWhat it does
deferred.isRejected()Learn jQuery deferred.isRejected(): check if a Deferred was rejected, why it was removed, use state() === \

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

Parameters

ParameterDescription
Step 1Create or receive a Deferred / Promise.
Step 2Call dfd.state() at a checkpoint (after reject, or inside fail).
Step 3Compare with === "rejected" for the old isRejected() meaning.

Return Value

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

jQuery Examples

Example 1 — After reject()

Once rejected, the modern check returns true.

jQuery
var dfd = $.Deferred();
dfd.reject("Network error");

var isRejected = dfd.state() === "rejected";
console.log(dfd.state());   // "rejected"
console.log(isRejected);   // true
Try It Yourself

How It Works

  1. Create a pending Deferred.
  2. Reject with a reason — state becomes "rejected".
  3. Compare state() === "rejected" (old isRejected()).

Example 2 — Still Pending

Before settle, the check is false.

jQuery
var dfd = $.Deferred();

console.log(dfd.state());                 // "pending"
console.log(dfd.state() === "rejected");  // false
Try It Yourself

How It Works

  1. Fresh Deferred starts as "pending".
  2. No reject yet — nothing has failed.
  3. Check === "rejected" → false.

Example 3 — After resolve()

Success is not rejection — the check stays false.

jQuery
var dfd = $.Deferred();
dfd.resolve("ok");

console.log(dfd.state());                 // "resolved"
console.log(dfd.state() === "rejected");  // false
Try It Yourself

How It Works

  1. Resolve settles as success → "resolved".
  2. Rejected? No — state is locked to resolved.
  3. Compare still yields false.

Frequently Asked Questions

isRejected() returned true when the Deferred had been rejected (fail path), and false while pending or after a successful resolve. It took no arguments.
No. It was deprecated in jQuery 1.7 and removed in 1.8. In current jQuery, use dfd.state() === "rejected" instead.
Call deferred.state(). It returns "pending", "resolved", or "rejected". Compare with === "rejected" for the old isRejected() meaning.
No. fail() registers a callback for when rejection happens. isRejected() (and state()) are synchronous status checks — they do not listen for future rejects.
At known checkpoints — after reject(), inside fail(), or for debugging. Prefer fail()/catch() for reacting to errors instead of polling.
No. Once settled, the state is locked. state() is "rejected" only after reject()/rejectWith(), never after resolve().

Next: jQuery.Deferred.exceptionHook() Method

See the legacy success check and its modern state() replacement.

jQuery.Deferred.exceptionHook() 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.

8 people found this page helpful