Example 1 — Custom this in done()
Pass a context object so the done handler can read this.id.
var ctx = { id: "uploader" };
var dfd = $.Deferred();
dfd.done(function (result) {
console.log(this.id + ": " + result); // uploader: complete
});
dfd.resolveWith(ctx, ["complete"]); How It Works
- Define context.
ctxholds anidthe handler needs. - Attach done. The callback uses
this.idand the result arg. - Resolve with context.
resolveWith(ctx, ["complete"])setsthis.

