title: How to get jstree to work properly with ajax loaded content
body: <p>For a project I am trying to create an ajax-powered treeview control. My ajax scripts are working fine on the back end, but the tree is not being displayed properly. When I hard code the ajax response into my tree container, it is displayed properly:</p>
  
  <p><img src="https://i.imgur.com/Yq88GZS.png" alt="correct"></p>
  
  <p>However, when I try to load the tree via ajax I get this:</p>
  
  <p><img src="https://i.imgur.com/B8QO1Ts.png" alt="incorrent"></p>
  
  <p>Here is my JS code:</p>
  
  <pre><code>$(document).ready(function() {
      function customMenu(node) {
          var items = {
              createItem : {
                  label : "Generate random number(s)",
                  action: function() {
                      console.log("Creating children...");
                      var selectedId = $("#treeview").jstree("get_selected").attr("id");
  
                      $.ajax({
                          type: "GET",
                          contentType: "application/json; charset=utf-8",
                          url: "libs/add.php",
                          data: "fact_id=" + selectedId,
                          dataType: "json",
                          success: function(data) {
                              console.log(data);
                          }
                      });
                  }
              }
          }
  
          return items;
      }
  
      $("#treeview").jstree({
          "plugins" : ["themes", "html_data", "ui", "crrm", "contextmenu"], contextmenu: {items: customMenu, select_node: true}
      });
  
      $.ajax({
          url: "libs/display.php",
          dataType: "json"
      }).success(function(data) {
          $("#treeview ul").append(data);
      });
  });
  </code></pre>
  
  <p>Does anyone have any idea what my problem is? Any help would be appreciated.</p>
  
  <p><strong>EDIT</strong>
  After looking closer, I realize that the exact problem is that the necessary classes are not being added to the child nodes when calling via ajax. Still, I'm not sure why.</p>
  
  <p><strong>ANOTHER EDIT</strong>
  <code>display.php</code> now contains this response text:</p>
  
  <pre><code>[
      {
          "attr": {
              "id": 1
          },
          "data": 649,
              "state": "closed"
      },
      {
          "attr": {
              "id": 1
          },
         "data": 108,
         "state": "closed"
      },
      {
          "attr": {
              "id": 1
           },
          "data": 86,
          "state": "closed"
      },
      {
          "attr": {
              "id": 1
          },
          "data": 46,
          "state": "closed"
       }
  ]
  </code></pre>
  
  <p>Am I headed in the right direction?</p>