Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8421447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:09:12+00:00 2026-06-10T03:09:12+00:00

I am using latest google chrome..I am trying to implement HTML5 indexedDB example. AIM

  • 0

I am using latest google chrome..I am trying to implement HTML5 indexedDB example. AIM is create database when page loads and store data in it. Please post any sample working example if any one have that.
I tried this code but I am getting Uncaught Error: InvalidStateError: DOM IDBDatabase Exception 11 when I am trying to create a transaction.
Here is the code snippet..

var idbRequest;
    var idb;
$(document).ready(function(){
    //ini----------------------
     var peopleData = [
                       { name: "John Dow", email: "john@company.com" },
                       { name: "Don Dow", email: "don@company.com" }
                   ];
    window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB;
    window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange;
    window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction;
    //create database.............
    if (window.indexedDB) {
          idbRequest = window.indexedDB.open("StoreDB");
          idbRequest.onsuccess =  function(e) {
              idb = idbRequest.result || e.result;  // FF4 requires e.result. IDBRequest.request isn't set :(
          /*idbRequest.onerror = function (evt) {
                  console.log("IndexedDB error: " + evt.target.errorCode);
              };*/
              var v = '2.0';
                var setVrequest = idb.setVersion(v);
                setVrequest.onsuccess = function(e) {
                    if(idb.objectStoreNames.contains("Stores")) {
                        alert("ObjectStore is already created.");
                        return false;
                      }
                    var objectstore = idb.createObjectStore("Stores");
                    alert("Object store Created.");
                    if (!idb.objectStoreNames.contains('Stores')) {
                          alert("Object store doesn't exist.");
                        return;
                      }else{
                          alert("Object store contain 'store'");
                      }

                       // Create a transaction that locks the world.
                     var trans = idb.transaction(["Stores"],"readwrite");//getting exception on this line..
                     trans.oncomplete = function(){
                          console.log("Success transaction");
                        };
                        var objectStore = trans.objectStore("Stores");
                      var request = objectStore.put(
                          1,
                          "wsdsdsd");
                    alert("data added");
                };






            };


    }   
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:09:13+00:00Added an answer on June 10, 2026 at 3:09 am

    Solved..
    I was getting error because we cannot create a transaction while version change is in progress..here is the final working answer..

    var idbRequest;
        var idb;
    $(document).ready(function(){
        //ini----------------------
    
        window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB;
        window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange;
        window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction;
        //create database.............
        if (window.indexedDB) {
              idbRequest = window.indexedDB.open("DB");
              idbRequest.onsuccess =  function(e) {
                  idb = idbRequest.result || e.result;  // FF4 requires e.result. IDBRequest.request isn't set :(
              /*idbRequest.onerror = function (evt) {
                      console.log("IndexedDB error: " + evt.target.errorCode);
                  };*/
                  var v = '2.0';
                    var setVrequest = idb.setVersion(v);
                    setVrequest.onsuccess = function(e) {
                        if(idb.objectStoreNames.contains("Stores")) {
                            alert("ObjectStore is already created.");
                            var vertrans = setVrequest.result;
                            vertrans.oncomplete = doStuff;
                            return false;
                          }
                        var objectstore = idb.createObjectStore("Stores");
                        alert("Object store Created.");
                        if (!idb.objectStoreNames.contains('Stores')) {
                              alert("Object stores doesn't exist.");
                            return;
                          }else{
                              alert("Object store contain 'stores'");
                          } 
                        var vertrans = setVrequest.result;
                        vertrans.oncomplete = doStuff;
                    };
    
                };
    
    
        }   
    });
    
    function doStuff(){
           // Create a transaction that locks the world.
        var trans = '';
    
             trans = idb.transaction(['Stores'],'readwrite');
    
         var objectStore = trans.objectStore('Stores');
          var request = objectStore.put(
              1,
              "wsdsdsd");
        alert("data added");
         trans.oncomplete = function(){
              console.log("Success transaction");
            };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the latest Google Chrome: On a page with just this inside body: <div
I am using latest Google IMA SDK for video ads, in that the flash
I'm using the latest tools provided by the latest Google App Engine (GAE) environment,
I am using the latest NHibernate 2.1.0Beta2. I'm trying to unit test with SQLite
I can't install the VirtualBox Guest Additions in the latest build of Google Chrome
I'm using the Google webfonts API to embed Droid Sans on a page. All
I'm using the latest version of Google App Engine, Python 2.7 and webapp2, but
I am using the latest Janrain openid library example and the discovery process seems
I'm trying to do a Google App Engine project on OS X (latest and
I've followed instructions http://code.google.com/webtoolkit/doc/latest/tutorial/gettingstarted.html in order to create sample GWT program. Now I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.