how to make json ajax call and pass it arguments?

1,933 views
Skip to first unread message

Radek Simcik

unread,
Jul 14, 2011, 11:26:16 PM7/14/11
to jstree
Hi

I want to use both the data and ajax config options. Basically the
ajax call will get data from the disk (test results) so I don't want
to pass all data when initializing jsTree the first time. Over the
time there will be more and more test results so ajax seems to me
great solution.

I managed to get it work to the point that ajax call was made (check
using firebug) but no data return from the server. I guess I missed
something here.

Also I need to pass the ajax call arguments the first one will be
parent/parent name and the other one will be parents name.

Have a look at sample http://jsfiddle.net/radek/G789k/

I also created a SO question here
http://stackoverflow.com/questions/6702313/how-to-make-json-ajax-call-in-jstree

Thank you for any help.

Radek

<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>

cimenta

unread,
Jul 17, 2011, 9:59:36 PM7/17/11
to jsTree
Somebody would know how to make AJAX work?

Thank you

R.

On Jul 15, 1:26 pm, Radek Simcik <radek.sim...@gmail.com> wrote:
> Hi
>

> I want to use both the data andajaxconfig options. Basically theajaxcall will get data from the disk (test results) so I don't want


> to pass all data when initializing jsTree the first time. Over the

> time there will be more and more test results soajaxseems to me
> great solution.
>
> I managed to get it work to the point thatajaxcall was made (check


> using firebug) but no data return from the server. I guess I missed
> something here.
>

> Also I need to pass theajaxcall arguments the first one will be


> parent/parent name and the other one will be parents name.
>

> Have a look at samplehttp://jsfiddle.net/radek/G789k/
>
> I also created a SO question herehttp://stackoverflow.com/questions/6702313/how-to-make-json-ajax-call...


>
> Thank you for any help.
>
> Radek
>
> <html>
>   <head>

>     <title>jsTree &ajax</title>

Rob Allen

unread,
Jul 18, 2011, 12:02:13 PM7/18/11
to jst...@googlegroups.com
I've posted an answer in reply to your SO thread. Hopefully it will help.
Reply all
Reply to author
Forward
0 new messages