と を使用Laravel 4
してfancytree
います。
次のようなデータapi
を返す呼び出しがあります。JSON
{
"error":false,
"survey_data":"[{
"id": 1,
"type": "group",
"subtype": null,
"title": "General ",
"parent": null,
"children": [{
"id": 30,
"type": "question",
"subtype": "boolean",
"title": "Did you..?",
"parent": 1,
"children": [{
"id": 31,
"type": "answer",
"subtype": null,
"title": "Yes",
"parent": 30,
"children": []
}]
}]
}]
}
JSON
of 要素survey_data
をにロードしたいfancytree
。
現在、私のコードは次のようなものです:
var tree = function (treeDiv,sourceURL){
treeDiv.fancytree({
source : sourceURL
})
}
変数sourceURL
に を渡し、正しいデータapi url
を取得していることを firebug で確認しました。JSON
しかし、これsurvey_data
JSON
をソースとしてロードする方法がわかりません。
私も試しました:
source: jQuery.ajax({
url: sourceURL,
type: 'GET',
dataType: 'json',
complete: function(xhr, textStatus) {
},
success: function(data, textStatus, xhr) {
return data.survey_data;
},
error: function(xhr, textStatus, errorThrown) {
}
})
しかし、エラーが発生します:
Uncaught Error: Assertion failed: source must contain (or be) an array of children
の最新バージョンを使用していることに注意してくださいfancytree
。
誰でも私を助けることができますか?
ありがとう。