PDA

View Full Version : Tree.TreeLoader({dataUri: 'foo/bar/foo'}); does not work?



Symbi0nt
5 Apr 2007, 6:21 AM
Hi there,

I am a little bit confused about the Tree widget.

I try to use the YUI-EXT Framework in combination with CakePHP (just some php-framework) and there are controller all over the place. So I set one up to give me the JSON Stuff back.

I *think* the very basic tree has just "text" and "id" stuff attached in a JSON array. But everything I tried does not show up.

I went back to the example and moved the 'get-nodes.php' file in a subdir to check if it can still load the data -> and it failed. Also with an absolute 'http://192.168.0.1/get-nodes.php' as the dataUri parameter does not work.

After giving google a try nearly 95% of all examples in the net have a just a simple filename there. My experices with Ajax.request from Prototype tells me that I usually can request any url with ajax. Are there any restrictions why I cant use a subdir or something?

I guess even an clean EXT application will get messy if every ajax call must be handled by a single file call (no subdir or so).

tab
5 Apr 2007, 6:28 AM
I am using JSON with parameters and subdirectories without problems. A useful way to find out what is going on is to use Firebug (I think it is under "console") to look at the request and reply. "LiveHttpHeaders" is another tool. I have found that you have to pay attention to how you frame the url and parameters, whether they end with a "/" or not is an issue.


Hi there,

I am a little bit confused about the Tree widget.

I try to use the YUI-EXT Framework in combination with CakePHP (just some php-framework) and there are controller all over the place. So I set one up to give me the JSON Stuff back.

I *think* the very basic tree has just "text" and "id" stuff attached in a JSON array. But everything I tried does not show up.

I went back to the example and moved the 'get-nodes.php' file in a subdir to check if it can still load the data -> and it failed. Also with an absolute 'http://192.168.0.1/get-nodes.php' as the dataUri parameter does not work.

After giving google a try nearly 95% of all examples in the net have a just a simple filename there. My experices with Ajax.request from Prototype tells me that I usually can request any url with ajax. Are there any restrictions why I cant use a subdir or something?

I guess even an clean EXT application will get messy if every ajax call must be handled by a single file call (no subdir or so).

Symbi0nt
5 Apr 2007, 6:49 AM
I am actually using FF and FireBug.

Can someone check this on his localhost? I have the lated download of ext extracted to the localhost and I'm using this url:

http://192.168.0.3/ext-1.0-beta1/examples/tree/reorder.html

which gives me the tree demo.

There is a reorder.js which will be called and in there there is a line like this:

loader: new Tree.TreeLoader({dataUrl:'get-nodes.php'}),

when I change this to either of the following lines ...

loader: new Tree.TreeLoader({dataUrl:'foo/get-nodes.php'}),
loader: new Tree.TreeLoader({dataUrl:'./foo/get-nodes.php'}),
loader: new Tree.TreeLoader({dataUrl:'http://192.168.0.3/ext-1.0-beta1/examples/tree/foo/get-nodes.php'}),

and put a 1:1 copy of the get-nodes.php into a foo subdirectory, so that this file really exists at that location. The tree has (after refresh) only a root node, which is static and nothing more happens.

The XHR Request returns nothing anymore, but hey it's just a subdirectory and it really exists. Drives me crazy.

[Edit]
When I call both get-nodes.php files manually They return both a long JSON tring, which looks ok.

tryanDLS
5 Apr 2007, 7:47 AM
Did you look at the Net tab in Firebug to see if the response looks OK. Also, try setting a BP in data.Connection in the handleResponse/handleFailure methods and see if you're getting there.