I want to make an ajax call to get data for results nodes. In my code example (see here), the ajax call is made, but the server does not return anything (verified using firebug). But if I use the same url in a web browser I can save the json file.
My questions:
- How to make ajax call work so return values โโare displayed in jsTree? It works beautifully here - search
Using both the data & ajax config options - how to pass ajax parameters
- would be the name of the parent / parent ( basics for the first node results)
- the second will be the parent name node ( login for the first node results)
See my code below or use fiddle
<html> <head> <title>jsTree & ajax</title> <script type="text/javascript" src="http://static.jstree.com/v.1.0pre/jquery.js"></script> <script type="text/javascript" src="http://static.jstree.com/v.1.0pre/_docs/syntax/!script.js"></script> <script type="text/javascript" src="http://static.jstree.com/v.1.0pre/jquery.cookie.js"></script> <script type="text/javascript" src="http://static.jstree.com/v.1.0pre/jquery.hotkeys.js"></script> <script type="text/javascript" src="http://static.jstree.com/v.1.0pre/jquery.jstree.js"></script> <script type='text/javascript'> data = [ { "data" : "Basics", "state" : "closed", "children" : [ { "data" : "login", "state" : "closed", "children" : [ "login", {"data" : "results", "state" : "closed"} ] } , { "data" : "Basics", "state" : "closed", "children" : [ "login", "something",{"data" : "results", "state" : "closed"} ] } ] }, { "data" : "All", "state" : "closed", "children" : [ { "data" : "AddCustomer", "state" : "closed", "children" : [ "login","Add", {"data" : "results", "state" : "closed"} ] } ] } ] $(function () { $("#jstree").jstree({ "json_data" : { "data" : data , "ajax" : { "url" : "http://www.jstree.com/static/v.1.0pre/_docs/_json_data.json" } }, "plugins" : [ "themes", "json_data" ] }); }); </script> </head> <body> <div id="jstree"></div> </body> </html>
Update 1
Even I copy the sample code from jstree.com to jsfiddle , this will not work. I guess I'm missing something ...
source share