Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
jQuery Deferreds and Promises
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Eli Perelman
November 01, 2011
Technology
390
10
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
jQuery Deferreds and Promises
My introduction slides from the Omaha Front-end Web and jQuery meetup on November 1, 2011.
Eli Perelman
November 01, 2011
More Decks by Eli Perelman
See All by Eli Perelman
Intro to Raptor
eliperelman
0
140
UI Synchronicity
eliperelman
1
160
Other Decks in Technology
See All in Technology
手塩にかけりゃいいってもんじゃない
ming_ayami
0
120
EventBridge Connection
_kensh
5
680
Databricks における 生成AIガバナンスの実践
taka_aki
1
370
AIっぽい文章を採点して人間らしく直すアプリを作ってみた
yama3133
2
110
Building applications in the Gemini API family.
line_developers_tw
PRO
0
2.6k
LLMと共に進化するプロセスを目指して
ymatsuwitter
12
3.8k
中期計画、2回作ってみた ~業務委託と正社員、両方の視点から~
demaecan
1
610
データ基盤をDataformで整えた話 〜 開発環境を添えて 〜
takapy
0
140
AI-DLCを活用した高品質・安全なAI駆動開発実践 / AI Driven Development with AI-DLC
yoshidashingo
0
160
10倍の生産性を実現するAI駆動並列エージェントのすべて
kumaiu
4
1.3k
2026.06.13_AI時代に事業会社が「SIer出身エンジニア」を求める理由 / Why Businesses Seek Engineers with a System Integrator Background in the AI Era
jumtech
0
1k
ブロックチェーン / Blockchain
ks91
PRO
0
120
Featured
See All Featured
Scaling GitHub
holman
464
140k
Statistics for Hackers
jakevdp
799
230k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
Amusing Abliteration
ianozsvald
1
200
Building AI with AI
inesmontani
PRO
1
1.1k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
570
How GitHub (no longer) Works
holman
316
150k
A Tale of Four Properties
chriscoyier
163
24k
Agile that works and the tools we love
rasmusluckow
331
21k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
The Invisible Side of Design
smashingmag
302
52k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
Transcript
jQuery Deferreds & Promises Eli Perelman @eliperelman
What are deferreds?
Provide a system to register callbacks into neatly managed queues
DEFERREDS
WITHOUT DEFERREDS var validateUser = function ( username, password, callback
) { if ( username === ‘bob’ && password === ‘123’ ) { callback( ‘success’ ); } else { callback( ‘failure’ ); } }; validateUser( ‘bob’, ‘123’, function ( result ) { if ( result === ‘success’ ) { location = ‘/dashboard’; } else { showError( ‘Invalid login.’ ); } });
WITH DEFERREDS var validateUser = function ( username, password )
{ var deferred = $.Deferred(); if ( username === ‘bob’ && password === ‘123’ ) { deferred.resolve(); } else { deferred.reject(); } return deferred.promise(); }; validateUser( ‘bob’, ‘123’ ) .done( function () { location = ‘/dashboard’; }) .fail( function () { showError( ‘Invalid login.’ ); });
Deferreds work with synchronous AND asynchronous functions.
Since jQuery 1.5, the $.ajax module uses deferreds.
What are promises?
Provide a common API for consuming code to register callbacks,
sync or async. PROMISES
Deferreds Promises .then .then .done .done .fail .fail .always .always
.reject .resolve .pipe .pipe .promise .promise .isResolved .isRejected
Coding time!