【发布时间】:2014-02-20 15:03:21
【问题描述】:
给定一个位于http://codio.io/hugolpz/Cat-is-smart/data/dict.json 的 JSON 文件。
鉴于我想加载它,然后显示它(把手放在它上面并使用它)。
我因此使用:
$.getJSON( "http://codio.io/hugolpz/Cat-is-smart/data/dict.json", function( json ) {
console.log("This step is fired."); // OR NOT !
alert( "JSON Data: " + JSON.stringify(json) );
});
或
$.ajax({
url: "http://codio.io/hugolpz/Cat-is-smart/data/dict.json",
dataType: 'json',
success: function(json2) {
alert( "JSON Data: " + JSON.stringify(json2) );
}
});
即使在同一个域上测试也不起作用。
我做错了什么?如何解决。
【问题讨论】:
-
您的 JSON 文件不正确。请从您的 json 文件中删除注释行。(注释行不被 json link 识别)