我正在使用jQuery从php文件中获取一些JSON数据。 我的数据是ut8编码并解码它(因为我已经明白,也许我错了)所以它 不会显示\ uXXX是使用parseJSON方法。
我的JSON数据是:
({"4":{"id":"88","label":"\u00eb\u00e9\u00fa\u00e4 \u00e0'","parent_id":"1","level":"1","children":[{"id":"92","label":"\u00e4\u00e9\u00f1\u00e8\u00e5\u00f8\u00e9\u00e4","parent_id":"88","level":"2","children":[{"id":"96","label":"\u00ee\u00e9\u00fa\u00e5\u00ec\u00e5\u00e2\u00e9\u00e4 \u00f0\u00e5\u00f8\u00e3\u00e9\u00fa","parent_id":"92","level":"3","children":[]}]},{"id":"90","label":"\u00ee\u00fa\u00ee\u00e8\u00e9\u00f7\u00e4","parent_id":"88","level":"2","children":[{"id":"97","label":"\u00ee\u00f9\u00e5\u00e5\u00e0\u00e5\u00fa","parent_id":"90","level":"3","children":[{"id":"98","label":"\u00f0\u00e5\u00f1\u00e7\u00e0\u00e5\u00fa","parent_id":"97","level":"4","children":[]}]}]}]},"5":{"id":"89","label":"\u00eb\u00e9\u00fa\u00e4 \u00e1'","parent_id":"1","level":"1","children":[]},"6":{"id":"91","label":"\u00eb\u00e9\u00fa\u00e4 \u00e2'","parent_id":"1","level":"1","children":[{"id":"93","label":"\u00e4\u00e9\u00f1\u00e8\u00e5\u00f8\u00e9\u00e4","parent_id":"91","level":"2","children":[{"id":"94","label":"\u00e4\u00e9\u00f1\u00e8\u00e5\u00f8\u00e9\u00e4 \u00e9\u00e4\u00e5\u00e3\u00e9\u00fa","parent_id":"93","level":"3","children":[]},{"id":"95","label":"\u00e4\u00e9\u00f1\u00e8\u00e5\u00f8\u00e9\u00e4 \u00e9\u00e5\u00e5\u00f0\u00e9\u00fa","parent_id":"93","level":"3","children":[]}]}]}});
我的JS是:
$(document).ready(function(){
$.getJSON(
'some url.../getJSON.php?callback=?',
function(data) {
data = jQuery.paresJSON(data);
$('#tree1').tree({
data: data
});
}
);
});
这没有输出任何内容,并向我显示上述错误。
任何想法我做错了什么?
先谢谢你们, 埃里克
答案 0 :(得分:3)
您的代码使用paresJSON
代替parseJSON
。
修正错字,这应该修复它。