您好我无法调用和使用(显示)我的JSON数据
我现在花了一段时间试图这样做,我可以说我错过了一些可能显而易见的东西......但它只是没有发生。
我的目标是从下面的JSON数组中获取并显示数据,形成另一个域/设备(移动应用程序)
我一直在寻找以下资源,并且暂时提出这个问题,但我似乎无法正常工作。
http://api.jquery.com/jQuery.getJSON/
How to get JSON from URL in Javascript?
我的数组(托管在上面的网址上)
[
{
"id":"1",
"category":"Mainstream",
"genre":"Action",
"title":"ALDNOAH.ZERO",
"description":"Humanity has clearly split into two and currently there is no way these groups will once again unite. Humanity celebrates this transient time of peace as they slowly dismiss from their minds the scars their ancestors bore in the past. No one realized that with one little push their world can fall to its destruction.",
"image_link":"aldnoanzero.jpg",
"date_added":"2015-02-17"
},
{
"id":"2",
"category":"Mainstream",
"genre":"Comedy",
"title":"SKET Dance",
"description":"At Kaimei High School, the Living Assistance Club (aka the Sket Brigade) was organized to help students with problems big or small. Most of the time, though, they hang out in their club room, bored, with only a few trivial problems floating in every once in a while. In spite of this, they still throw all their energy into solving these worries.",
"image_link":"sketdance.jpg",
"date_added":"2015-02-17"
},
{
"id":"3",
"category":"Hidden Gems",
"genre":"Science Fiction",
"title":"Time of eve",
"description":"Time of Eve (Eve no jikan) series is the latest work by Yasuhiro YOSHIURA, who stunned the anime world with Pale Cocoon and Aquatic Language (Mizu no kotoba).",
"image_link":"timeofeve.jpg",
"date_added":"2015-02-17"
}
]
答案 0 :(得分:1)
您需要您的端点(您正在访问JSON的页面)将访问控制允许来源设置为所有来源,以便浏览器可以发出客户端请求。
如果已完成,那么您可以使用jQuery $. get()
方法来访问JSON数据。
答案 1 :(得分:0)
我认为XMLHttpRequest无法加载https://nani.io/json_data.json 请求的资源上没有“Access-Control-Allow-Origin”标头。