我正在尝试传递和检索隐藏变量中的JSON数据并遇到奇怪的情况。我一直绞尽脑汁,到处搜寻,找出原因 - 我确定它有些愚蠢,但我想不出是什么......:
原木取自铬,但firefox表现出相同的行为。 请参阅下面的代码和控制台日志。
503 var pp = $("#new-event-page").find("input[name=event_data]").val();
504 console.log(pp);
505 // comment
506 var paramx = JSON.parse(pp);
507 //comment
508 console.log(JSON.stringify(paramx));
509 console.log(paramx);
控制台日志的输出如下(在一些手动格式化之后):
testa.js:504--{"name":"Untitled-1369464011",
"description":"Previously aadded image - only this text is updated",
"occurred":"2013-05-25",
"group":"empty",
"category":"empty",
"_attachments":{"globe.png":{"content_type":"image/png",
"digest":"md5d8ba0496f16bdf74d6310432abf2a530"}},
"_id":"0C1CA0F4-2DF4-46F2-9D35-415674D6452A",
"_rev":"5-1d108457b606cc4388160ca46ffefbbf"}
testa.js:508--{"name":"Untitled-1369464011",
"description":"Previously aadded image - only this text is updated",
"occurred":"2013-05-25",
"group":"empty",
"category":"empty",
"_attachments":{"globe.png":{"content_type":"image/png",
"digest":"md5-d8ba0496f16bdf74d6310432abf2a530"}},
"_id":"0C1CA0F4-2DF4-46F2-9D35-415674D6452A",
"_rev":"5-1d108457b606cc4388160ca46ffefbbf"}
testa.js:509--Object {name: "Untitled-1369464011", description: "Previously aadded image - only this text is updated", occurred: "2013-05-25", group: "empty", category: "empty"…}
_attachments: Object
globe.png: Object
content_type: "image/png"
__proto__: Object
opAAAAAElFTkSuQmCC: Object
content_type: undefined
__proto__: Object
__proto__: Object
_id: "0C1CA0F4-2DF4-46F2-9D35-415674D6452A"
_rev: "6-001ee0c89c5b9dbe2b06e5b926ad446d"
category: "empty"
description: "Previously aadded image - only this text is updated -pass 2"
group: "empty"
name: "Untitled-1369464011"
occurred: "2013-05-25"
__proto__: Object