jquery error when trying to load tree data from ajax call returning JSON data

319 views
Skip to first unread message

roy.and...@gmail.com

unread,
Oct 20, 2015, 4:34:49 AM10/20/15
to Fancytree Q&A
I am having problems trying to load tree data from an ajax call to a PHP webservice. The service call completes and I am happy with the data being returned. I have checked it with JSONLint and it validates. However the Chrome's developer tools window show an error "Uncaught Error: Not Implemented" in file jquery-1.11.3.min.js:2

The page displays a white band where I would expect to see the tree displayed but no data is displayed.
I am using the following references:
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.min.js" type="text/javascript"></script>
<!-- Include Fancytree skin and library -->
<link href="../fancytree/dist/skin-win8/ui.fancytree.min.css" rel="stylesheet" type="text/css">
<script src="../fancytree/dist/jquery.fancytree-all.min.js" type="text/javascript"></script>

and the code on the page is thus:
<div id="tree"></div>
<script type="text/javascript" defer="defer">
$(function(){
var ver = $().jquery;
alert(ver);

var phpAPI = "http://localhost/clubjudge/api/JSONClassTree2";
$.getJSON( phpAPI)
.done(function( json) {
alert(json);

$("#tree").fancytree({
source: json
}
);
})
.fail(function( jqxhr, textStatus, error ) {
var err = textStatus + ", " + error;
console.log( "Request Failed: " + err );
});

});
</script>

There are a couple of alerts in there so I can figure out what's going on. Any ideas much appreciated.

adam.g...@gmail.com

unread,
Feb 6, 2018, 8:42:48 AM2/6/18
to Fancytree Q&A
Probably json is string in your case and FancyTree expects it to be JS Object, so you should use JSON.parse() first.

mar10

unread,
Feb 9, 2018, 1:47:56 AM2/9/18
to Fancytree Q&A
I'd recommend to stick to the demos and documentation and pass the URL directly to the `source` option instead of calling $.getJSON and create the tree in the response.
Reply all
Reply to author
Forward
0 new messages