I'm having an issue while populating a FancyTree tree via the ajax call option. The source of the page and the tree data is PL/SQL package from an Oracle 10 database. I call tree_test.show_page
and it uses htp.p
to display this simple test page (script links removed for clarity):
<html>
<head>
<title>Tree Testing</title>
<script type="text/javascript">
$(function() {
// Create the tree inside the <div id="tree"> element.
$("#tree").fancytree({
checkbox: true, // Show checkboxes.
debugLevel: 2, // 0:quiet, 1:normal, 2:debug
selectMode: 3, // 1:single, 2:multi, 3:multi-hier
source: {
url: "tree_test.get_tree",
dataType: "json",
cache: true
}
}); // end of fancytree def
});
</script>
</head>
<body>
<p>Tree structure:</p>
<div id="tree"></div>
</body>
</html>
The tree doesn't display, but in the Chrome debugger I can see where the call to test_tree.get_tree
was successfully made. I'm assuming that the issue is that the string response is not being seen as JSON data. I know the data is good because if I add var treeData = <JSON data here>
and change the FancyTree source
parameter to source: treeData
, it works fine. And the tree data is supplied by the same PL/SQL procedure regardless of which way the source
parameter is configured.
In the Chrome debugger, it shows the content-type of the response as
text/html
(see edit below). I've tried various values for the dataType
parameter ("json", "html json", "text json", "html text json", etc) with no success.
Am I missing something obvious??
Below is the sample JSON data:
[{title: "Root Group", key: "g0", folder: true, expanded: true, children: [{title: "Group 1", key: "g1", folder: true, expanded: true, children: [{title: "Node 1", key: "141", tooltip: "Node 1"},{title: "Node 2", key: "82", tooltip: "Node 2"}]},{title: "Group 2", key: "g2", folder: true, expanded: true, children: [{title: "Node 3", key: "91", tooltip: "Node 3"}]}]}]
Edit:
By suggestion of Yogi, I added owa_util.MIME_HEADER('application/json', true)
to the tree_test.get_tree
procedure and now the content-type of the response shows as application/json
in Chrome's debugger. But the tree still doesn't get populated with data.
This is not valid JSON data, but a JavaScript object dump:
[{title: "Root Group", key: "g0", folder: true, expanded: true, children: [{title: "Group 1", key: "g1", folder: true, expanded: true, children: [{title: "Node 1", key: "141", tooltip: "Node 1"},{title: "Node 2", key: "82", tooltip: "Node 2"}]},{title: "Group 2", key: "g2", folder: true, expanded: true, children: [{title: "Node 3", key: "91", tooltip: "Node 3"}]}]}]
it should be
[{"title": "Root Group", "key": "g0", "folder": true, ...
See http://json.org/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.