JavaScript & jQuery Tutorials

JQ Home Right Arrow Objects Right Arrow 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 Objects Objects   go 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:

Related Tutorials

jQuery Advanced Tutorials - Lesson 7 - The Deferred Object


go to jQuery home page jQ Home go to Objects Objects go to top of page Top