Please take a look at this jsFiddle: http://jsfiddle.net/xY7tx/3108/
请看看这个jsFiddle:http://jsfiddle.net/xY7tx/3108/
When I run getJSON
in the above sample, why is the fail
part always triggered?
当我在上面的示例中运行getJSON时,为什么总是触发失败部分?
I would really appreciate if one tell me how with jQuery (or even with pure Javascript) How could get the key and value of the JSON file.
如果有人告诉我如何使用jQuery(甚至使用纯Javascript),我真的很感激。如何获得JSON文件的密钥和值。
My goal is after getting the key (title
) and the value (video_url
) then insert them all into a list ul
which the items of the list are the keys and the href
are their values. Thanks
我的目标是在获取密钥(标题)和值(video_url)之后将它们全部插入到列表ul中,列表中的项目是键,href是它们的值。谢谢
1 个解决方案
#1
2
Because it's not JSON data. You're getJSON
ing an HTML page.
因为它不是JSON数据。你得到一个HTML页面.JSONing。
Try it with the following link:
尝试使用以下链接:
$.getJSON("https://raw.githubusercontent.com/xldrx/kodi-persian-contents/master/movies/movies.json", function(d) {
console.log(d);
}).fail( function(d, textStatus, error) {
alert("getJSON failed \n , status: " + textStatus + "\n "+ ", error: "+error + "\n")
});
As for the list, not sure I fully understood your requirement, but is this what you're looking for: https://jsfiddle.net/p77ymjgx/ ?
至于列表,不确定我是否完全理解您的要求,但这是您正在寻找的:https://jsfiddle.net/p77ymjgx/?
#1
2
Because it's not JSON data. You're getJSON
ing an HTML page.
因为它不是JSON数据。你得到一个HTML页面.JSONing。
Try it with the following link:
尝试使用以下链接:
$.getJSON("https://raw.githubusercontent.com/xldrx/kodi-persian-contents/master/movies/movies.json", function(d) {
console.log(d);
}).fail( function(d, textStatus, error) {
alert("getJSON failed \n , status: " + textStatus + "\n "+ ", error: "+error + "\n")
});
As for the list, not sure I fully understood your requirement, but is this what you're looking for: https://jsfiddle.net/p77ymjgx/ ?
至于列表,不确定我是否完全理解您的要求,但这是您正在寻找的:https://jsfiddle.net/p77ymjgx/?