【发布时间】:2012-01-01 11:16:28
【问题描述】:
我在这里和谷歌上搜索过,但作为一个没有经验的 Javascript 黑客,我正在努力寻找一个我认为是相当直接的行动的好例子。
我有一个服务器端脚本,我已对其进行编码以提供 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?
提前致谢。 皮特
【问题讨论】:
-
我为 facebook 应用程序编写了自己的 json Dropbox 输出。一个工作示例显示在@apps.facebook.com/fileglu/technical
标签: javascript jquery ajax json multidimensional-array