We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I got a JS-Error when I try to get data via Url:
Uncaught TypeError: can't convert undefined to object
This is the code:
const myTree = new Tree('#myTree', { url: 'http://localhost:8000/treeviewJson', method: 'GET', });
But this works:
let url = 'http://localhost:8000/treeviewJson'; fetch(url) .then(res => res.json()) .then(out => { const myTree = new Tree('#myTree', { data: [out], }) } );
This is the response of the URL
# curl http://localhost:8000/treeviewJson {"id":"0","text":"Node 0","children":[{"id":1,"text":"Node 0-1"},{"id":2,"text":"Node 0-2"}]}[]
It's generate by PHP:
function treeviewJson(): Response { $data = [ 'id' => '0', 'text' => 'Node 0', 'children' => [ [ 'id' => 1, 'text' => 'Node 0-1' ], [ 'id' => 2, 'text' => 'Node 0-2' ], ] ]; $response = new Response(); $response->setContent(json_encode($data)); $response->headers->set('Content-Type', 'application/json'); return $response; }
The text was updated successfully, but these errors were encountered:
I get the same exception: #25
Sorry, something went wrong.
maybe just my 2cent but your return should be an array itself like
$data = [ [ 'id' => '0', 'text' => 'Node 0', 'children' => [ [ 'id' => 1, 'text' => 'Node 0-1' ], [ 'id' => 2, 'text' => 'Node 0-2' ], ] ] ];
that will result in this json
[ { "id": "0", "text": "Node 0", "children": [ { "id": 1, "text": "Node 0-1" }, { "id": 2, "text": "Node 0-2" } ] } ]
No branches or pull requests
I got a JS-Error when I try to get data via Url:
This is the code:
But this works:
This is the response of the URL
It's generate by PHP:
The text was updated successfully, but these errors were encountered: