deferred.progress()S2C Home « Objects « deferred.progress()

Callback progression.

Description

The deferred.progress() Deferred method, adds handlers to the Deferred object that are called on progress notification generation.

  • Callbacks are executed in the order they were added and each callback is passed the args from the respective method if any were specified.
  • When the Deferred generates progress notifications by calling the deferred.notify() or deferred.notifyWith() methods, the progressCallbacks are called.
  • Any progressCallbacks added after the Deferred object enters the resolved or rejected state are ignored.

Syntax

Signature Description
deferred.progress( progressCallbacks )Add handlers to the Deferred object that are called on progress notification generation.

Parameters

Parameter Description Type
progressCallbacksA function(s), or array(s) of functions, that are called when the Deferred is notified.Function

Return

A Deferred object.

deferred.progress( progressCallbacks ) ExamplesTop

Add handlers to the Deferred object that are called on progress notification generation.

In the example below when we press the button the first time, we create a Deferred object . We then notify and resolve the Deferred object and process any progressCallbacks and doneCallbacks.


$(function(){
  $('#btn15').one('click', function(){
    var ourDeferred = $.Deferred();
    ourDeferred.progress( eFunc );
    ourDeferred.done( eFunc );
    ourDeferred.notify( 'Our deferred was notified. <br>', '#div1');
    ourDeferred.resolve( 'Our deferred was resolved. <br><br>', '#div1');
  });

  function eFunc( value, div ){
    $(div).append( 'In eFunc: ' + value);
  }
});

div1. Some initial text.

Press the button below to action the above code: