(function ($) {
    var slice = Array.prototype.slice;
    $.defer = function (func, delay) {
        var args = slice.call(arguments, 2),
            isCancelled = false,
            cancel = function (reject /* = true */) {
                clearTimeout(timerId);
                isCancelled = true;
                if ((!arguments.length || reject) && deferred.state() === "pending") {
                    deferred.reject(null, promise, args);
                }
            },
            deferred = $.Deferred(),
            timerId = setTimeout(function () {
                deferred.notify(promise, args);
                if (isCancelled) {
                    return;
                }
                try {
                    var result = func.apply(this, args);
                    deferred.resolve(result, promise, args);
                } catch (e) {
                    deferred.reject(e, promise, args);
                }
            }, delay),
            promise = deferred.promise();

        promise.cancel = cancel;
        return promise;
    };
})(jQuery);

(function ($) {
    var slice = Array.prototype.slice;
    $.defer = function (func, delay) {
        var args = slice.call(arguments, 2),
            cancel = function (reject /* = true */) {
                clearTimeout(timerId);
                if ((!arguments.length || reject) && deferred.state() === "pending") {
                    deferred.reject(null, promise, args);
                }
            },
            deferred = $.Deferred(),
            timerId = setTimeout(function () {
                deferred.notify(promise, args);
                // if they cancel inside the progress call-back...
                if (deferred.state() === "rejected") {
                    return;
                }
                try {
                    var result = func.apply(this, args);
                    deferred.resolve(result, promise, args);
                } catch (e) {
                    deferred.reject(e, promise, args);
                }
            }, delay),
            promise = deferred.promise();

        promise.cancel = cancel;
        return promise;
    };
})(jQuery);
--- 
+++ 
@@ -2,8 +2,10 @@
     var slice = Array.prototype.slice;
     $.defer = function (func, delay) {
         var args = slice.call(arguments, 2),
+            isCancelled = false,
             cancel = function (reject /* = true */) {
                 clearTimeout(timerId);
+                isCancelled = true;
                 if ((!arguments.length || reject) && deferred.state() === "pending") {
                     deferred.reject(null, promise, args);
                 }
@@ -11,8 +13,7 @@
             deferred = $.Deferred(),
             timerId = setTimeout(function () {
                 deferred.notify(promise, args);
-                // if they cancel inside the progress call-back...
-                if (deferred.state() === "rejected") {
+                if (isCancelled) {
                     return;
                 }
                 try {
Fix the initial cancel bug
