JSTree1.0 beta2... AJAX doesn't work

55 views
Skip to first unread message

denis.kolkovskiy

unread,
Feb 8, 2010, 8:01:49 AM2/8/10
to jsTree
Hi,

First of all thanks for your work ! JSTree is a very nice plugin. :)

But now I have problems.I can't configure JSTree in order to make AJAX
request to the HTTP handler.
See configuration below:

$("#" + treeID).jstree({
json_data: {
ajax: {
async: true,
url: GetHTTPHandlerUrl("RemoteServerFSHandler.ashx"),
dataType: "json",
type:"GET",
success: function() { alert("SUCCESS"); },
error: function(XMLHttpRequest, textStatus, errorThrown)
{ debugger; }
}
}
,
plugins: ["json_data", "themes", "ui"],

I always receive error:

This method cannot be called until the send method has been called.

Don't sure if it's error in JQuery 1.4.1 or in JSTree.

Thanks in advance!

zontar

unread,
Feb 9, 2010, 4:04:51 AM2/9/10
to jsTree
Hi,

I've managed to make the tree works async with AJAX+JSON..here is my
config

jQuery("#jstree_1").jstree({
json_data : {
async : true,
ajax : {
url : URL_AJAX, //"./data.json",
dataType : "json",
data : function (n) {
return { "id" : n == -1 ? 0 :
n[0].id };
}
}
},
themes : { theme: "default", dots : true },
plugins : [ "json_data", "themes", "ui", "search" ],
search : {
//search still doesn t work
}
}
});

URL_AJAX is an url pointint to a server that will receive an id, and
send back (as in v 0.9.9a) a list of child nodes.
The syntax has slightly changed, due I think to Jquery 1.4.
attributes are now called attr, and every name of json attribute must
be enclosed in double quotes..


[
{ "attr": {"id" : "n1"}, "data": "Nodo 1 Pesce", "state": "closed"}
,{ "attr": {"id" : "n2"}, "data": "Nodo 2 Carne", "state": "closed"}
,{ "attr": {"id" : "n3"}, "data": "Nodo 3 Verdura", "state": "closed"}
,{ "attr": {"id" : "n4"}, "data": "Nodo 4 Frutta ", "state": "closed"}
]

Here is a working snippet..

Hope it helps

regards

Walter
On Feb 8, 2:01 pm, "denis.kolkovskiy" <denis.kolkovs...@itechart-

vakata

unread,
Feb 13, 2010, 9:15:56 AM2/13/10
to jsTree
Sorry about that ajax was non working in beta2 - it will be in beta3
or just use the latest from the SVN

Cheers,
Ivan

Reply all
Reply to author
Forward
0 new messages