简体   繁体   English

未捕获的 DOMException:无法从“IDBRequest”读取“结果”属性:请求尚未完成

[英]Uncaught DOMException: Failed to read the 'result' property from 'IDBRequest': The request has not finished

I'm binding data to 3 dropdowns by calling a method from another file of javascript.我通过调用另一个 javascript 文件中的方法将数据绑定到 3 个下拉列表。 The data source of dropdown loading from IndexedDB.从 IndexedDB 下拉加载的数据源。 Data binding JS,数据绑定JS,

function bindStateData(){
     getMstStates("#state");
     getMstStates("#drstate");
     getMstStates("#cstate");
   }

Database manager js,数据库管理器js,

function getMstStates(state) {
    var request = indexedDB.open('AppDatabase', '3')
    request.onsuccess = function (e) {
        var dbInstance = e.target.result;
        let transaction = dbInstance.transaction("MstStates", "readonly");
        const statesDetailsStore = transaction.objectStore("MstStates");
        stateData = statesDetailsStore.getAll();
        stateData.onsuccess = function () {
            var MstStatesMap = new Object();
            var len = stateData.result.length,
            i;
            for (i = 0; i < len; i++) {
                MstStatesMap[i] = {};
                MstStatesMap[i].StateId = stateData.result[i].StateId;
                MstStatesMap[i].StateName = stateData.result[i].StateName;
            }
            callBackOptionItems(MstStatesMap, state);
        }
        stateData.onerror = function () {
            console.log('getMstStates : ' + e);
        }
     }
    request.onerror = function (e) { console.log('getMstStates : ' + e); }
}

function callBackOptionItems(MstOptionMap, objID) {
    for (var j in MstOptionMap) {
        var k, v
        var tem = 0;
        for (var i in MstOptionMap[j]) {
            if (tem == 0) {
                k = MstOptionMap[j][i]
            } else {
                v = MstOptionMap[j][i];
            }
            tem++
        }
        var el = $(objID);
        $(el).append('<option value="' + k + '">' + v + '</option>');

    }
    if (objID == '#select-history') {
        $("#select-history").append('<option value="4">Other</option>');
    }
}

When I tried to loading data I got the following error,当我尝试加载数据时,出现以下错误,

Uncaught DOMException: Failed to read the 'result' property from 'IDBRequest': The request has not finished.
    at IDBRequest.stateData.onsuccess

The same code logic was written in WebSQL, it was running properly, but unfortunately from iOS 13 version websql support has been revoked.相同的代码逻辑用 WebSQL 编写,运行正常,但不幸的是从 iOS 13 版本 websql 支持已被撤销。

I have resolved this issue.我已经解决了这个问题。 The main culprit line is,罪魁祸首是,

var len = stateData.result.length;

The correct code is as follows,正确的代码如下,

    var _request = statesDetailsStore.getAll();
    _request.onsuccess = function (event) {
        var MstStatesMap = new Object();
        var stateData = event.target.result;
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Uncaught InvalidStateError:无法从'IDBRequest'读取'result'属性:请求尚未完成 - Uncaught InvalidStateError: Failed to read the 'result' property from 'IDBRequest': The request has not finished 未捕获的DOMException:无法从“ CSSStyleSheet”读取“ cssRules”属性 - Uncaught DOMException: Failed to read the 'cssRules' property from 'CSSStyleSheet' 未捕获的 DOMException:无法从“CSSStyleSheet”读取“规则”属性 - Uncaught DOMException: Failed to read the 'rules' property from 'CSSStyleSheet' 未捕获的 DOMException:无法读取“cssRules”属性 - Uncaught DOMException: Failed to read the 'cssRules' property Iframe chrome:未捕获的 DOMException:无法从“窗口”读取“localStorage”属性:拒绝访问此文档 - Iframe chrome : Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document 未捕获的DOMException:无法读取“ contentDocument” - Uncaught DOMException: Failed to read the 'contentDocument' 未捕获的 DOMException:无法使用 JQuery 设置“innerHTML”属性 - Uncaught DOMException: Failed to set the 'innerHTML' property using JQuery Javascript:DOMException:无法从“CSSStyleSheet”读取“cssRules”属性:无法访问规则 - Javascript: DOMException: Failed to read the 'cssRules' property from 'CSSStyleSheet': Cannot access rules 未捕获的SecurityError:无法从“ HTMLIFrameElement”读取“ contentDocument”属性:阻止了框架 - Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame Uncaught SecurityError:无法从'HTMLIFrameElement'读取'contentDocument'属性 - Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM