Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript “是否存在”的回调;chrome.storage.local.set“;_Javascript_Google Chrome Extension - Fatal编程技术网

Javascript “是否存在”的回调;chrome.storage.local.set“;

Javascript “是否存在”的回调;chrome.storage.local.set“;,javascript,google-chrome-extension,Javascript,Google Chrome Extension,只有在设置了Chrome.storage.local之后,我才需要发回Chrome消息,但是我找不到一种方法来“导入”其中的sendResponse函数 请考虑所有这些代码都被执行到背景脚本 >和>强> >从Cordon脚本和/或从浏览器动作弹出窗口发送的消息< /强>触发。所以这就是为什么我需要回复 你知道吗 的回调签名为: 但你却通过了: function (sendResponse) { console.log(`documents_cache ha

只有在设置了Chrome.storage.local之后,我才需要发回Chrome消息,但是我找不到一种方法来“导入”其中的
sendResponse
函数

请考虑所有这些代码都被执行到<强>背景脚本<强> >和>强> >从Cordon脚本和/或从浏览器动作弹出窗口发送的消息< /强>触发。所以这就是为什么我需要回复


你知道吗 的回调签名为:

但你却通过了:

        function (sendResponse) {
            console.log(`documents_cache has been saved`);
            documents = new Array(); // Empty the array

            sendResponse("documents have been loaded and saved!"); // <-- this does not work
        }
综上所述,只需将回调更改为
。将
设置为不接受任何参数:

        function () {
            console.log(`documents_cache has been saved`);
            documents = new Array(); // Empty the array

            sendResponse("documents have been loaded and saved!"); // <-- this does not work
        }
函数(){
log(`documents\u cache已保存`);
documents=new Array();//清空数组
sendResponse(“文档已加载并保存!”)//
// Recursive ajax call
function get_and_merge_data(cursor = null, token, sendResponse) {
        function () {
            console.log(`documents_cache has been saved`);
            documents = new Array(); // Empty the array

            sendResponse("documents have been loaded and saved!"); // <-- this does not work
        }