JsTree loading data?

I am trying to use the JsTree v3.0.

This loads the data into the tree.

'core' : {
  'data' : {
    'url' : function (node) {
      return node.id === '#' ? 
        'ajax_roots.json' : 
    'data' : function (node) {
      return { 'id' : node.id };

Open in new window

Q1) I also saw you can use the .ajax inside of above code.
What's the difference?
THis one use .ajax to request.

    "plugins": ["json_data", "themes", "ui", "crrm", "dnd", "search", "contextmenu"],
      "json_data" : 
    [quote]    "ajax" : 
            "url" : "{{ url('components/tree/findall') }}",
[/quote]                       "data" : function (node) { 
                     return {   
                            "operation" : "get_children",
                            "id" : node.attr ? node.attr("id").replace("node_","") : 1

Open in new window

Who is Participating?
Scott Fell, EE MVEConnect With a Mentor Developer & EE ModeratorCommented:
If this is something that is used on multiple pages or is a very large file size, it is a good idea to use ajax and load from a url on your server.
lenamtlConnect With a Mentor Commented:
Depending of your needs and server configuration

With Ajax:
The only difference is that the JSON is not inside the config object, but returned from the server.

dkim18Author Commented:
I should had made url to contain same name in both example above.
Let's assume that they are both coming from the web service.

What's the difference?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.