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


- 如何显示带有换行符的文本标签? 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01