deferred.state() JQ Home  <<  Objects  <<  deferred.state()

Deferred state.

Description

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

Syntax

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

Parameters

None.

Return

A String object.

deferred.state() ExamplesObjects  <<  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.


$(function(){
  $('#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