admin管理员组文章数量:1429399
I got a very simple txt file in JSON format:
{
"menu": "File1",
"bday": [
{
"name": "teo",
"date":"22"
},
{
"name": "john",
"date": "9"
},
{
"name": "maria",
"date": "15"
}
]
}
All I want is to just fetch the data and print them. Like:
teo : 22
john:9
...etc...
I don't care about this. I just want to fetch the data.
I got a very simple txt file in JSON format:
{
"menu": "File1",
"bday": [
{
"name": "teo",
"date":"22"
},
{
"name": "john",
"date": "9"
},
{
"name": "maria",
"date": "15"
}
]
}
All I want is to just fetch the data and print them. Like:
teo : 22
john:9
...etc...
I don't care about this. I just want to fetch the data.
Share Improve this question edited Oct 11, 2012 at 17:42 Peter Mortensen 31.6k22 gold badges110 silver badges133 bronze badges asked Jan 29, 2011 at 1:29 t0st0s 1,2195 gold badges19 silver badges28 bronze badges2 Answers
Reset to default 3Your answer is plainly XMLHttpRequest, which is multi-browser patible JavaScript without need for a library. You can always create your own library for some backward-patibility.
Put the JSON in a file on your server (for example, data.js
) and then use jQuery to fetch the file. Something like this:
var json;
$.getJSON("data.js", function(data){
json = data;
});
本文标签: javascriptFetch JSON data from a fileStack Overflow
版权声明:本文标题:javascript - Fetch JSON data from a file - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745544227a2662631.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论