Load JSON file issue in jsTree v3.04

843 views
Skip to first unread message

Guoliang Xiang

unread,
Oct 9, 2014, 9:47:02 AM10/9/14
to jst...@googlegroups.com
Hi, I tried to use jsTree to create a tree link in a jsp page. But it is just not working for me so far.
The jsTree version I used is v3.04, and my project is based on Spring MVC

The js code like:

<script type="text/javascript">
$(function () { 
    $('#tree').jstree({
'core' : {
 'data' : {
   'url' : 'bo.json'
 }
}
});
});
</script>

The div in jsp page like:
<div id="tree" ></div>

The json file like:

[
{ "id" : "ajson1", "parent" : "#", "text" : "Simple root node" },
{ "id" : "ajson2", "parent" : "ajson1", "text" : "Root node 2" },
{ "id" : "ajson3", "parent" : "ajson2", "text" : "Child 1" },
{ "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" }


The result I got is just a loading sign, and the log in the firebug is 404 Not Found jquery.js (line 8102) HTTP Status 404 - 

Your help will be greatly appreciated,

Sean

Ivan Bozhanov

unread,
Oct 9, 2014, 10:31:36 AM10/9/14
to jst...@googlegroups.com
That simply means there is something wrong with your server config - the file can not be found - "bo.json" is obviously not where it should be - try an absolute path for example (sorry but there is no way for me to help you further as this is an issue with your setup, not jstree).
Also - I hope you are not running this from the local file system (URL in browser address bar starting with "file://") - if so - most browsers won't make AJAX calls for security reasons.

Best regards,
Ivan

Guoliang Xiang

unread,
Oct 9, 2014, 11:01:27 AM10/9/14
to jst...@googlegroups.com
The browsers may be the issue. I tested the jsTree demo files in my laptop without any change and I can see the tree structure for "Using Ajax" section is keep loading. Here is the download file I tested /jstree_3.04/demo/filebrowser/data/root/index.html#/docs/json

The bo.json file I placed at the same folder with the jsp file in my application, and that will not be a issue.

Thank you for your suggestion, and I think I still need to figure out the solution.

Regards,

Sean

Ivan Bozhanov

unread,
Oct 9, 2014, 11:41:07 AM10/9/14
to jst...@googlegroups.com
Sorry, I can't help you any further.
Since you are getting a 404 - just take a look at the console, click open in new tab and see where the request goes off to. I can only assure you it is not an issue with jstree.

Best regards,
Ivan

Jean-Philippe Tourne

unread,
Jan 22, 2020, 9:40:55 AM1/22/20
to jsTree

Bonjour Guoliang Xiang

I can see this post is 5 years old.
Did you get to solve the load of the json content into a jstree ?

Having the same issue here : infinite load.

Jean-Philippe

Jean-Philippe Tourne

unread,
Jan 23, 2020, 8:02:35 AM1/23/20
to jsTree

I published my content onto IIS in my C:\inetpub\wwwroot folder.
Then i ran the url from http://localhost/
The tree did work after that operation.
It seems ajax is blocked on a local machine.

J
Reply all
Reply to author
Forward
0 new messages