1

已解决 - 请参阅此帖子下的最后一条评论。

我试图在隐藏变量中传递和检索 JSON 数据并遇到一个奇怪的情况。我一直在绞尽脑汁,到处寻找原因——我敢肯定这是愚蠢的,但我想不出是什么……:

  1. 第 504 行和第 508 行显示了正确的数据(描述字段除外,这是唯一更改的字段),但第 509 行显示了 _attachments 下的另一个对象,该对象在其他两个中不存在 - 为什么?
  2. 第 509 行 - 标题行描述文本与对象主体中的描述文本不同 - 主体描述是正确的。

原木取自铬,但 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
4

1 回答 1

0

嗯,我看不到错误FF 21:http: //jsfiddle.net/A3tex/

给出: 在此处输入图像描述

于 2013-05-25T11:32:25.483 回答