【发布时间】:2013-03-20 03:21:53
【问题描述】:
我需要从本地主机读取.json 文件,但它不起作用!
文件内容如下:
[
{"source":"tw1",
"text":"fubar"},
{"source":"tw2",
"text":"foo"}
]
我使用以下命令设置了 localhost:python -m http.server 8888 &,这里发布了D3.js。
我编写了以下 javascript 代码:
<script type="text/javascript" src="lib/jquery-1.9.1.js"></script>
<script>
$(document).ready(
$.getJSON("http://localhost/test.json", function(data){
document.write(data);
});
</script>
【问题讨论】:
-
我同意@Amberlamps。请编辑问题并显示您遇到的错误。
-
对不起,我没有收到任何错误,我什么也没收到,这就是问题之一
标签: javascript json localhost