我试图使用fancytree来显示从PHP休息服务返回的一些数据。服务返回的数据已通过JSONLint进行验证,并以fancytree文档中显示的格式显示。fancytree not loading json数据
如果我有开发人员工具窗口(Chrome)打开它显示文件jquery-1.11.3.min.js:2中的错误“未捕获的错误:未实现”。
当我验证了返回的JSON数据时,我使用高级休息客户端(Google App),并删除了包含Advanced Rest Client显示的字符串的双引号,然后将值粘贴到JSONLint中。
我的jQuery代码:
<script type="text/javascript">
$(function(){
var phpAPI = "http://localhost/clubjudge/api/JSONClassTree2";
$.getJSON(phpAPI)
.done(function(json) {
alert(json);
$("#tree").fancytree({
source: json
}
);
})
.fail(function(jqxhr, textStatus, error) {
var err = textStatus + ", "+ error;
console.log("Request Failed: "+ err);
});
});
</script>
任何帮助非常赞赏,因为我一直在现在这个搞乱了几天。 PS。我希望包含的代码格式正确。 '预览'似乎看起来不正确。
想像我最好发布JSON数据。
[
{"title":"A - Australian Native","key":"1","children":[
{"title":"A1 - Australian Native Dendrobium Species","key":"7"},
{"title":"A2 - Australian Native Any Other Species","key":"8"},
{"title":"A3 - Australian Native Dendrobium Hybrid","key":"9"},
{"title":"A4 - Australian Native Any Other Hybrid","key":"10"},
{"title":"A5 - Australian Native Seedling","key":"11"}
]},
{"title":"B - Cymbidium","key":"2","children":[
{"title":"B1 - Standard Type Cymbidium","key":"3"},
{"title":"B2 - Intermediate Type Cymbidium","key":"4"},
{"title":"B3 - Miniature Type Cymbidium","key":"5"},
{"title":"B4 - Cymbidium Species","key":"6"}
]}
]
对不起,我意识到有很多。再一次,这是Advanced Rest Client显示的内容(修剪掉外部双引号后)。