Your Search Results

    IDBRequest.readyState

    This article is in need of a technical review.

    « IDBRequest

    The IDBRequest.readyState property returns the state of the request.

    Every request starts in the pending state. The state changes to done when the request completes successfully or when an error occurs.

    Syntax

    readonly  attribute IDBRequestReadyState  readyState;

    Example

    var title = "Walk dog";
    
    // Open up a transaction as usual
    var objectStore = db.transaction(['toDoList'], "readwrite").objectStore('toDoList');
    
    // Get the to-do list object that has this title as it's title
    var request = objectStore.get(title);
    
    request.onsuccess = function() {
      // Grab the data object returned as the result
      var data = request.result;
     
      // Update the notified value in the object to "yes"
      data.notified = "yes";
     
      // Create another request that inserts the item back into the database
      var requestUpdate = objectStore.put(data);
    
      // Log the ready state of this request
      console.log("The ready state of this request is " + request.readyState);
     
      // When this new request succeeds, run the displayData() function again to update the display
      requestUpdate.onsuccess = function() {
        displayData();
      };
    };

    Value

    The IDBRequestReadyState of the request:

    Value Meaning
    pending The request is pending.
    done The request is done.

    Specifications

    Specification Status Comment
    Indexed Database API Candidate Recommendation  

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
    Basic support

    12 -webkit

    23

    4.0 (2.0)

    16

    10 17 Not supported
    Feature Android Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
    Basic support 4.4 6.0 (6.0) 1.0.1 10 17 Not supported

    Be careful in Chrome as it still implements the old specification along the new one. Similarly it still has the prefixed webkitIndexedDB property even if the unprefixed indexedDB is present.

    See also

    • Using IndexedDB
    • The reference application for the examples in this reference: To-do Notifications (view example live.) Not every snippet appears in this example, but every example uses the same data structure and syntax, and they will make sense in the context of this example.

    Document Tags and Contributors

    Contributors to this page: chrisdavidmills
    Last updated by: chrisdavidmills,