Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
jQuery Deferreds and Promises
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Eli Perelman
November 01, 2011
Technology
410
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
150
UI Synchronicity
eliperelman
1
170
Other Decks in Technology
See All in Technology
CTO Night & Day Morning Session_AI-DLC:生成 AI 時代の開発プロセス変革
pikosan0000
0
120
Flutter Widget Previewerで始めるUIプレビューとVRTの自動化
sakusaku3939
0
160
AI駆動開発における開発環境のセキュリティの考え方
yamahiro
2
660
VLA-JEPA: Enhancing Vision-Language-Action Models with Latent World Models
takmin
0
370
Vue で書く 空間コンピューティング、TresJS と WebXR を使ったXR デバイスのフロントエンド開発
hiranuma
0
130
AI駆動開発におけるハーネスエンジニアリングの勘所
tsukuboshi
1
840
GitHub、使う?使わない?
happysamurai294
0
110
[FECONF-2026] 신대륙을 향한 카카오페이증권 프론트엔드 항해기 (이주승)
l1ghthouse
0
270
AI秘書と毎日働くのはもう当たり前。開発以外の業務に足りない機能をどう埋める?
minorun365
PRO
4
1.9k
ドメインエキスパートは いかにして AI を使って プロダクト開発をするか
tatsuyashiraishi
1
220
Don't write the architecture only in the prompt.
neohsu
0
230
Claude for Google Workspaces ポン出し/claude-for-google-workspace-slide-conversion
emiki
0
13k
Featured
See All Featured
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
290
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
290
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.6k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
650
Color Theory Basics | Prateek | Gurzu
gurzu
1
500
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
340
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!