Hi,
You can not use the success callback to make changes to the JSON that jstree receives. You have two options:
Option 1)
Use the built-in jQuery "dataFilter" method:
'data' : {
'url' : ...
'dataFilter' : function (data) {
// process the data any way you want (console.log(data) to see what you have, transform it and return the new object)
// keep in mind for some jQuery versions (older ones) you will have to return a string and not an object - if that is the case "return JSON.stringify(new_data);" will do
return new_data;
}
Option 2)
Instead of having jstree make the AJAX calls for you, set core.data to a function, make the call yourself and return the processed object to jstree (I will be using your code from above):
data : function (node, cb) {
$.ajax(
"url" : "//
www.jstree.com/fiddle/?lazy",
"data" : { "id" :
node.id },
"success": function(data) {
cb([{"id": 1, "text": "Updated Root node", }, {"id": 2, "text":
"Updated Child node 1", "parent": 1, "children": true}]);
}
);
}
Notice that instead of return the callback function is executed.
Best regards,
Ivan