と を使用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": []
}]
}]
}]
}
JSONof 要素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。
誰でも私を助けることができますか?
ありがとう。