我需要你的幫助。我正在使用indexedDB
。我需要使用Javascript
從數據庫中的表中讀取記錄,但我收到來自Chrome瀏覽器V52的錯誤消息未捕獲InvalidStateError:未能從'IDBRequest'中讀取'result'屬性:請求尚未完成。Uncaught InvalidStateError:無法從'IDBRequest'中讀取'result'屬性:請求尚未完成
下面是我的Javascript代碼
VAR分貝; var availableJobs = 0;
window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
var request = window.indexedDB.open("MyDbName", 1);
request.onsuccess = function (event) {
db = request.result;
}
request.onblocked = function (event) {
db = "blocked...";
};
request.onerror = function (event) {
db = "Error...";
};
var objectStore = db.transaction("ActionCard").objectStore("ActionCard");
objectStore.openCursor().onsuccess = function (event) {
var cursor = event.target.result;
if (cursor) {
if (cursor.value.ActionCardStatusId == 1 || cursor.value.ActionCardStatusId == 3) {
availableJobs++;
}
cursor.continue();
}
$("#availableJobs").html(availableJobs);
}
我在這一行
var objectStore = db.transaction("ActionCard").objectStore("ActionCard");
雖然我在'onsuccess'函數中爲它賦值,它看起來像變量'db'始終爲'null'。 – Linda