Skizit Skizit - 1 year ago 255
JSON Question

Chrome sendrequest error: TypeError: Converting circular structure to JSON

I've got the following...

req: "getDocument",
docu: pagedoc,
name: 'name'
}, function(response){
var efjs = response.reply;

which calls the following..

case "getBrowserForDocumentAttribute":
alert("ZOMG HERE");
reply: getBrowserForDocumentAttribute(request.docu,

However, my code never reaches "ZOMG HERE" but rather throws the following error while running

Uncaught TypeError: Converting circular structure to JSON

Does anyone have any idea what is causing this?

Answer Source

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 cannot convert structures like this.

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download