我已經在這裏和谷歌上搜索過,但作爲一個沒有經驗的Javascript黑客,我正在努力尋找一個我認爲是一個相當直接的行動的好例子。將JavaScript數據檢索到JSON數據的指導
我有一個服務器端腳本,我編碼提供JSON格式的輸出(content.php?action = json)。
的JSON輸出是多維的,即,它被格式化爲...
[Content]
[Class 1]
[Entry 1]
[Entry 2]
[Entry 3]
...
[Class 2]
[Entry 1]
[Entry 2]
...
兩者的類和表項的數量是可變的。
我現在想寫一個簡單的JavaScript來執行下列操作...
1) Call my PHP script
2) Copy the returned JSON output into a suitable Javascript array
3) Display parts of this array within my HTML pages
有一些這個難題的「位」,但我在努力把這個在一起。有人會給我一個簡單的例子嗎?
一對夫婦的面問題...
(i) Does the output file containing the JSON data need to have it's HTML headers altered to indicate it's content type?
(ii) Is jQuery the best approach for this sort of thing?
在此先感謝。 皮特
我寫的Dropbox我自己的JSON輸出的Facebook應用程序。一個工作示例顯示在@ http://apps.facebook上。com/fileglu/technical –