nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / jqTree / _entries / 48_loaddatafromurl.md
1 ---
2 title: loadDataFromUrl
3 name: functions-loaddatafromurl
4 ---
5
6 **function loadDataFromUrl(url);**
7
8 **function loadDataFromUrl(url, parent_node);**
9
10 **function loadDataFromUrl(parent_node);**
11
12 Load data in the tree from an url using ajax. You can **replace the whole tree** or you can **load a subtree**.
13
14 {% highlight js %}
15 $('#tree1').tree('loadDataFromUrl', '/category/tree/');
16 {% endhighlight %}
17
18 Load a subtree:
19
20 {% highlight js %}
21 var node = $('#tree1').tree('getNodeById', 123);
22 $('#tree1').tree('loadDataFromUrl', '/category/tree/123', node);
23 {% endhighlight %}
24
25 You can also omit the url. In this case jqTree will generate a url for you. This is very useful if you use the load-on-demand feature:
26
27 {% highlight js %}
28 var $tree = $('#tree1');
29
30 $tree.tree({
31     dataUrl: '/my_data/'
32 });
33
34 var node = $tree.tree('getNodeById', 456);
35
36 // jqTree will load data from /my_data/?node=456
37 $tree.tree('loadDataFromUrl', node);
38 {% endhighlight %}
39
40 You can also add an **on_finished** callback parameter that will be called when the data is loaded:
41
42 **function loadDataFromUrl(url, parent_node, on_finished);**
43
44 **function loadDataFromUrl(parent_node, on_finished);**
45
46 {% highlight js %}
47 $('#tree1').tree(
48     'loadDataFromUrl',
49     '/category/tree/123',
50     null,
51     function() {
52         alert('data is loaded');
53     }
54 );
55 {% endhighlight %}