SyntaxStudy
Sign Up
jQuery Introduction to jQuery Deferred
jQuery Intermediate 4 min read

Introduction to jQuery Deferred

jQuery Deferred

jQuery's Deferred object is a chainable utility for managing asynchronous operations. It is jQuery's predecessor to native Promises, with a similar API.

Example
const deferred = $.Deferred();

deferred.done(function(value) {
  console.log("Resolved:", value);
}).fail(function(reason) {
  console.log("Rejected:", reason);
});

// Resolve it later
setTimeout(() => deferred.resolve("success!"), 1000);
Pro Tip

jQuery Deferred objects are compatible with native Promise in jQuery 3.x.