I’m writing a JavaScript/HTML5 Windows 8 app. I occasionally get a InvalidStateError when writing to the IndexedDB. My function is below and it happens on the first line. Is there a way to ensure that the State is correct?
**newEncryptedInfo is a JSON object with 2 string parameters (for the time being). It is properly formed.
function loadData(evt) {
var transaction = EncryptedDB.db.transaction("data", "readwrite");
var encryptStore = transaction.objectStore("data");
var addResult = encryptStore.add(newEncryptedInfo);
}
If you get an InvalidStateError when creating a transaction, then the cause is usally because the db connection is closed. Click here for more info about it.