Chrome sendrequest error: TypeError: Converting circular structure to JSON(Chrome sendrequest 错误:TypeError:将循环结构转换为 JSON)
问题描述
我有以下...
chrome.extension.sendRequest({
req: "getDocument",
docu: pagedoc,
name: 'name'
}, function(response){
var efjs = response.reply;
});
它调用以下..
case "getBrowserForDocumentAttribute":
alert("ZOMG HERE");
sendResponse({
reply: getBrowserForDocumentAttribute(request.docu,request.name)
});
break;
但是,我的代码从未到达ZOMG HERE",而是在运行 chrome.extension.sendRequest
However, my code never reaches "ZOMG HERE" but rather throws the following error while running chrome.extension.sendRequest
Uncaught TypeError: Converting circular structure to JSON
chromeHidden.JSON.stringify
chrome.Port.postMessage
chrome.initExtension.chrome.extension.sendRequest
suggestQuery
有人知道是什么原因造成的吗?
Does anyone have any idea what is causing this?
推荐答案
表示你在请求中传入的对象(我猜是pagedoc
)有循环引用,类似于:
It means that the object you pass in the request (I guess it is pagedoc
) has a circular reference, something like:
var a = {};
a.b = a;
JSON.stringify
不能像这样转换结构.
JSON.stringify
cannot convert structures like this.
注意:DOM 节点就是这种情况,它们具有循环引用,即使它们没有附加到 DOM 树.每个节点都有一个 ownerDocument
,它在大多数情况下引用 document
.document
至少通过 document.body
引用 DOM 树,而 document.body.ownerDocument
引用回 document
再次,这只是 DOM 树中多个循环引用中的 一个.
N.B.: This would be the case with DOM nodes, which have circular references, even if they are not attached to the DOM tree. Each node has an ownerDocument
which refers to document
in most cases. document
has a reference to the DOM tree at least through document.body
and document.body.ownerDocument
refers back to document
again, which is only one of multiple circular references in the DOM tree.
这篇关于Chrome sendrequest 错误:TypeError:将循环结构转换为 JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Chrome sendrequest 错误:TypeError:将循环结构转换为 JSON
基础教程推荐
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 动态更新多个选择框 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 悬停时滑动输入并停留几秒钟 2022-01-01