Converting circular structure to JSON
管理系统在firefox开发,目前要兼容google chrome 。。firefox 下一切正常运行,但是在google chrome下出现这个错误提示:Converting circular structure to JSON
MiscUtils.clone = function(object) {
return JSON.parse(JSON.stringify(object)); //出现错误提示代码行
};
网络上关于这个错误的说明:
It means that the object you pass in the request (I guess it ispagedoc) has a circular reference, something like:
var a = {}; a.b = a;JSON.stringifycannot 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 anownerDocumentwhich refers todocumentin most cases.documenthas a reference to the DOM tree at least throughdocument.bodyanddocument.body.ownerDocumentrefers back todocumentagain, which is onlyoneof multiple circular references in the DOM tree.
最后的解决方法:
MiscUtils.clone = function(object) {
return object;
};
该方法的功能是克隆一个对象,传过来的参数也是一个object类型,所以就没有必要先转成string ,然后再转成object类型。。