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

Deferred state.


The deferred.state() Deferred method, returns a string representing the current state of a Deferred object.


Signature Description
deferred.state()Determine the current state of a Deferred object.




A String object.

deferred.state() Examplesgo to top of page Top

Determine the current state of a Deferred object.

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.

  $('#btn16').one('click', function(){
    var ourDeferred = $.Deferred();
    ourDeferred.always( eFunc );
    $('#div1').append( 'Current state of ourDeferred: ' + ourDeferred.state() + ' <br />');
    ourDeferred.resolve( 'Our deferred was resolved. <br />', '#div1');
    $('#div1').append( 'Current state of ourDeferred: ' + ourDeferred.state() + ' <br />');

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

div1. Some initial text.

Press the button below to action the above code:

go to home page Homepage go to top of page Top