The isRejected() method returns true when a jQuery Deferred has failed — and false while it is still pending or after a successful resolve. This tutorial covers syntax, return values, five examples, comparisons with state(), and when not to poll this method.
01
Syntax
dfd.isRejected()
02
true
Rejected state
03
false
Pending / resolved
04
state()
Modern jQuery 3+
05
vs fail()
Check vs callback
06
Timing
After settle
Fundamentals
Introduction
Callbacks like fail() react when a Deferred rejects. Sometimes you need a quick synchronous answer: has this task already failed?isRejected() answers that question with a boolean — no callback registration required.
Use it for conditional debugging, branching in test helpers, or inspecting Deferred state at a known checkpoint. For production error handling, prefer fail() or catch() — they fire automatically when rejection happens, without polling.
Concept
Understanding the isRejected() Method
isRejected() is a state query on jQuery’s Deferred object. It returns true only when the Deferred has entered the rejected state via reject(), a failed AJAX call, or a rejected promise in a chain.
It returns false when the Deferred is still pending (work not finished) or resolved (success). A Deferred can only settle once — it never flips from rejected back to resolved.
💡
Beginner Tip
Do not call isRejected() immediately after starting async work — the old reference example checked right after setTimeout was scheduled, which always returned false. Check inside fail() or after reject() runs.
Foundation
📝 Syntax
General form of deferred.isRejected:
jQuery
deferred.isRejected()
Return value
true — the Deferred has been rejected (failed).
false — the Deferred is still pending or was resolved successfully.
Modern alternative (jQuery 3+)
jQuery
if (dfd.state() === "rejected") {
console.log("The operation failed");
}
Cheat Sheet
⚡ Quick Reference
Deferred state
isRejected()
state()
Pending
false
"pending"
Resolved
false
"resolved"
Rejected
true
"rejected"
Compare
📋 isRejected() vs fail() vs state()
Three ways to interact with rejection — choose based on whether you need a callback or a snapshot.
isRejected()
boolean
Sync state snapshot
fail()
callback
Runs on reject
state()
"rejected"
jQuery 3+ preferred
Timing
after settle
Not while pending
Hands-On
Examples Gallery
Each example shows when isRejected() returns true or false. Use the Try-it links to run them interactively.
📚 Getting Started
See isRejected() return true only after rejection.
isRejected() and state() === "rejected" agree on rejected Deferreds. Use state() when you also need to distinguish pending from resolved.
Applications
🚀 Use Cases
Error state detection — confirm a Deferred failed before running recovery logic.
Conditional branching — choose different code paths in tests or debug utilities based on rejection.
Dynamic UI updates — show error panels when state() is "rejected" after async UI loads.
Logging — record rejection status alongside other Deferred metadata during diagnostics.
Multi-task coordination — inspect individual Deferreds returned from $.when() after a batch completes.
🧠 When isRejected() Returns What
1
Pending
Work in progress — isRejected() is false.
Wait
2
Settled
Deferred resolves or rejects — state locks permanently.
Final
3
Query
isRejected() returns true only for the rejected branch.
Check
=
🔍
Informed action
Combine with fail() for reactions and state() for readable status in jQuery 3+.
Important
📝 Notes
isRejected() is deprecated in jQuery 3.0+ — use state() === "rejected" in new code.
Never assume false means success — it can also mean still pending.
Prefer fail() over polling isRejected() in production error handling.
isRejected() and isResolved() are never both true on the same Deferred.
For jqXHR from $.ajax(), the same state rules apply once the request completes.
Compatibility
Browser Support
deferred.isRejected() has been available since jQuery 1.5. It remains supported in jQuery 3.x but is deprecated — prefer state().
✓ jQuery 1.5+
jQuery Deferred.isRejected()
Works in jQuery 1.5+, 2.x, and 3.x wherever Deferred objects run. Deprecated since jQuery 3.0 in favor of state().
100%With jQuery loaded
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
deferred.isRejected()Universal
Bottom line: Safe in legacy jQuery codebases. For new jQuery 3+ projects, write dfd.state() === "rejected" instead.
Wrap Up
🎉 Conclusion
The deferred.isRejected() method tells you whether a Deferred has failed. Use it for synchronous state checks at the right moment — after rejection or inside fail() — and prefer state() in modern jQuery code.
Next, explore isResolved() for the success counterpart, or review state() for a single API that covers all three statuses.
isRejected() returns true when the Deferred has been rejected (failed). It returns false while the Deferred is still pending or after it has been resolved successfully.
Only after the Deferred may have settled — inside a fail() callback, after reject(), or when you know async work finished. Calling it immediately while a timer or AJAX request is still pending always returns false.
In jQuery 3.0+, isRejected() and isResolved() are deprecated in favor of state(), which returns "pending", "resolved", or "rejected". Both still work; prefer dfd.state() === "rejected" in new code.
fail() registers a callback that runs when rejection happens. isRejected() is a synchronous boolean check of current state — it does not register a listener.
No. Once resolved or rejected, the state is locked. isRejected() is true only for the rejected state; isResolved() is true only for the resolved state.
Usually no. Prefer fail(), catch(), or always() callbacks. Polling isRejected() in a tight loop wastes CPU; use callbacks or state() checks at known checkpoints instead.
Did you know?
jQuery added state() in version 1.7 as a single way to read "pending", "resolved", or "rejected". In jQuery 3.0, isRejected() and isResolved() were deprecated because state() covers every case in one call.