title: Passing data from MVC controller to jsTree through ajax calls.
body: <p>I have a jsTree with a parent node and 5 children nodes. They function fine. I am trying to implement a dynamic jsTree where with click of a node, an ajax call should pass that node's ID to my java MVC spring-boot controller and a Map with keys as child nodes' IDs and value as names of child nodes. </p>
  
  <p>So far I have managed to get the value of the clicked child node's ID and pass it to my java controller through ajax call. But I'm not able to proceed further as I am not sure how to structure the data that is passed from controller to ajax call which in turn has to implement the jsTree. 
  Here's the code of my existing jsTree - </p>
  
  <pre><code>&lt;div id="container"&gt;
   &lt;ul&gt;
     &lt;li id = "id1"&gt;Root
        &lt;ul&gt;
          &lt;li id="id 1-1"&gt;child 1&lt;/li&gt;
          &lt;li id="id 1-2"&gt;child 2&lt;/li&gt;
          &lt;li id="id 1-3"&gt;child 3&lt;/li&gt;
          &lt;li id="id 1-4"&gt;child 4&lt;/li&gt;
          &lt;li id="id 1-5"&gt;child 5&lt;/li&gt;       
        &lt;/ul&gt;
     &lt;/li&gt;
   &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here's the code of my ajax -jquery call that passes the nodeID to the controller- </p>
  
  <pre><code>$(function() {
    $('#container').on('changed.jstree', function (e, data) {
      var i, j, r = [], rid = [];
      for(i = 0, j = data.selected.length; i &lt; j; i++) {
        r.push(data.instance.get_node(data.selected[i]).text);
        rid.push(data.instance.get_node(data.selected[i]).id);
      }
      console.clear();
      console.log('Selected: ' + r.join(', '));
      console.log('Selected id: ' + rid.join(', '));
      $.ajax({
          type: 'GET',
          url: "http://localhost:8080/tree/object?nodeID="+rid.join(', '),
          contentType: 'text/plain',
          crossDomain: false,
          async:true,
          success:function() {
  
              }   
      });
    })
    .jstree();
  });
  </code></pre>
  
  <p>I'm limited by my knowledge of jsTree, ajax and jquery. Any help would be appreciated. I am looking into the documentation of jsTree: filling the tree through ajax calls <a href="https://www.jstree.com/docs/html/" rel="nofollow noreferrer">here</a>.</p>