2011-05-24 31 views
0

hihi我正在做一個關於ajax(xmlHttRequest)的項目, 我如何打電話給筆記會話中的標題,因爲通常如果你打電話給開始年就像detail = eval.... then for loop it inside should be var start year="" startyear += ...[i].startyear 這樣的事情,但我怎麼樣打電話給筆記裏面的標題? 我嘗試調用detail.notes.note.title它說的是空或不是一個對象給定的錯誤在Ajax請求中發送json數組?使用javascript

這是JSON數據:

{ 
"infos": { 
    "info": [ 
     { 
      "startYear": "1900", 
      "endYear": "1930", 
      "timeZoneDesc": "daweerrewereopreproewropewredfkfdufssfsfsfsfrerewrBlahhhhh..", 
      "timeZoneID": "1", 
      "note": { 
       "notes": [ 
        { 
         "id": "1", 
         "title": "Mmm" 
        }, 
        { 
         "id": "2", 
         "title": "Wmm" 
        }, 
        { 
         "id": "3", 
         "title": "Smm" 
        } 
       ] 
      }, 
      "links": [ 
       { 
        "id": "1", 
        "title": "Red House", 
        "url": "http://infopedia.nl.sg/articles/SIP_611_2004-12-24.html" 
       }, 
       { 
        "id": "2", 
        "title": "Joo Chiat", 
        "url": "http://www.the-inncrowd.com/joochiat.htm" 
       }, 
       { 
        "id": "3", 
        "title": "Bake", 
        "url": "https://thelongnwindingroad.wordpress.com/tag/red-house-bakery" 
       } 
      ] 
     } 
    ] 
} 

}

+2

嗚。標點符號,語法和拼寫可能會使這個問題變得可以理解。 – Hyperboreus 2011-05-24 02:44:54

+0

@Hyperboreus你知道嗎? – cutexxbaby 2011-05-24 02:51:28

+0

您的解析器將無法讀取您的JSON,因爲它格式不正確。嘗試修復它,然後嘗試再次解析。 – Hyperboreus 2011-05-24 02:54:34

回答

0

使用http://jsonlint.com/來幫助你與JSON 。

我得到這個...

Parse error on line 30: 
...   ]  } 
----------------------^ 
Expecting '}', ',', ']' 
+0

已經改變,所以你知道應該如何在註釋會話中調用標題(數組) – cutexxbaby 2011-05-24 03:24:52

+0

detail.notes.note.title < - 你叫它錯了detail.infos.info.no​​te.notes應該是正確的:) – user766987 2011-05-24 03:39:18

+0

我試試你的然後它說錯誤...爲空或不是一個對象 – cutexxbaby 2011-05-24 03:45:33

相關問題