deferred.state() returns a string for the current Deferred status (since jQuery 1.7). It takes no arguments. Official docs note it is mainly useful for debugging — for example, checking whether something already resolved when you expected a reject.
Remember
deferred.state() → String
"pending" → not settled yet
"resolved" → resolve() / resolveWith() ran
"rejected" → reject() / rejectWith() ran
once settled → state never changes
prefer callbacks over polling state()
Call it with no arguments; compare the returned string.
Hold a Deferred or its promise().
Call state() at a checkpoint (after a settle, in a test, while debugging).
Compare to "pending", "resolved", or "rejected".
For normal async flow, attach done/fail/then instead of looping on state().
Piece
Required?
Role
Arguments
None
Method takes no parameters
Return
—
"pending" | "resolved" | "rejected"
Since
—
jQuery 1.7
Pseudocode
Pseudocode
state():
if not settled yet: return "pending"
if resolve / resolveWith was called: return "resolved"
if reject / rejectWith was called: return "rejected"
// after either settle:
// state() always returns the same string
Reference
Cheat Sheet
Keep these facts handy when inspecting Deferred status.
Topic
Detail
Syntax
deferred.state()
Values
pending · resolved · rejected
On Promise
Yes — read-only via promise()
Settled?
state() !== "pending"
vs callbacks
Inspect now vs react later
Best use
Debug / tests / one-shot checks
Since
jQuery 1.7
Try it
Live Preview
Settle a Deferred different ways and watch state() change.
Browser demo of deferred.state — same idea as the examples below.
Result
state() → "pending"
/* neither resolve nor reject yet */
Code
jQuery Examples
Short, copy-ready snippets. Open the browser console, or use Try It Yourself for a live editor.
Example 1 — Fresh Deferred Is Pending
Before any settle call, state() is "pending".
jQuery
var dfd = $.Deferred();
console.log(dfd.state()); // pending
Create a Promise view.promise() shares the same status.
Inspect safely.p.state() works; p.resolve does not exist.
Owner settles. Only dfd can resolve.
Promise updates.p.state() becomes "resolved".
Example 5 — Branch on Current State
Use a one-shot check when you may already be settled (not a polling loop).
jQuery
function label(dfd) {
var s = dfd.state();
if (s === "pending") return "still working";
if (s === "resolved") return "success";
return "failed";
}
var dfd = $.Deferred();
console.log(label(dfd)); // still working
dfd.resolve();
console.log(label(dfd)); // success
Read once.label calls state() at the moment you ask.
Map to words. Three strings → three friendly labels.
Before settle. Shows still working.
After resolve. Shows success — a checkpoint check, not a busy loop.
Edge Cases & Pitfalls
Check these before relying on state() in real projects.
poll
Do not poll in a tight loop
Busy-waiting on state() burns CPU. Prefer done/fail/always for completion.
locked
State never flips back
After resolve or reject, state() stays that value forever for that Deferred.
debug
Official primary use is debugging
Docs highlight checking whether a Deferred already resolved when you meant to reject — great for tests and logs.
legacy
Prefer state() over boolean helpers
isResolved() / isRejected() only cover two cases; state() covers all three in one call.
Compatibility
Browser Support
deferred.state() needs jQuery 1.7+ loaded. It works across jQuery 1.7–3.x on both Deferreds and Promises from promise().
✓ jQuery 1.7+
deferred.state()
Works in Chrome, Firefox, Safari, and Edge when jQuery 1.7+ is loaded. Returns pending, resolved, or rejected.
100%With jQuery 1.7+
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
state()Universal
Bottom line: Safe wherever modern jQuery Deferreds exist. Use callbacks for flow control; use state() for inspection.
Analysis
Performance Notes
Approach
Cost
Best for
state() once
O(1)
Debug / checkpoint
done / fail
Event-driven
Normal completion handling
Polling state()
Wastes CPU
Avoid
A single state() read is cheap. The anti-pattern is spinning until it changes — register handlers instead.
Remember
Key Takeaways
Role: return pending, resolved, or rejected.
Locked: after settle, the string never changes.
Promise OK: inspect status without settle methods.
Prefer callbacks for flow; use state() for inspection.
One line:state() tells you where a Deferred is now — pending, resolved, or rejected.
Frequently Asked Questions
A string: "pending" before settlement, "resolved" after resolve()/resolveWith(), or "rejected" after reject()/rejectWith(). Once settled, the value never changes.
state() returns one of three strings in a single call. isResolved() and isRejected() return booleans. Prefer state() — the boolean helpers are older and less convenient.
Yes. Promises expose state() for read-only inspection without allowing resolve or reject.
Use state() for a synchronous check at a known point (debug, tests, branching after possible settlement). To react when work finishes, prefer done(), fail(), then(), or always().
Yes. A Deferred stays pending until the owner calls resolve, reject, or a *With variant.
Usually no. Polling wastes CPU. Register callbacks, or check state() once at logical checkpoints.