View Full Version : [SOLVED] data from php page loads if echo "hardcoded" but not if echo func_output()

20 May 2010, 4:15 PM
[UPDATE] So after much unneeded effort, I figured out the problem. my string, as I say, was "nicely formatted" - that is, it had indentations via $indent = "&nbsp;" and a number of <br>'s here and there to make it a readable structure. THIS IS WHERE THE ISSUE WAS. The reason the output appeared fine but wouldn't render in my TreePanel, yet it did when I copied that output, was because those <br>'s and indentations were not part of the output copying I put into an echo. So note to anyone who has the same (stupid?) issue: format something all you want when testing, but take out that formatting when you've got it working! It's too bad I didn't know about this issue - would've saved me hours of trying to find a solution and stressing about not finding one. Cheers!




This is perplexing the heck out of me. I have a function that returns a nicely formatted string for my treepanel. At the end of my php file I say "echo construct_group_hierarchy()" and if I view the php page in firefox, the output looks good. So I assume it's ok to use:

dataUrl: tree_data.php

when making my tree.

Apparently not so. In order to get the data properly, instead of that call:

echo construct_group_hierarchy()

I copy that data and have to HARD-CODE it as the output (and comment out the function call). EVEN THOUGH BOTH PRODUCE THE SAME OUTPUT.

Can someone explain to me how to fix this, or why it's happening? It just drives me nuts that although both produce the same output, the output cannot be echoed as a function, but must be hardcoded text.



20 May 2010, 7:31 PM
You'd probably have better mileage posting this on a php forum...

21 May 2010, 7:14 AM
I'll see what I can dig up. It looks like echo func() doesn't return a bonafide string or something like that. So I tried removing all the functions I had so the file was just a straight php file read top to bottom and echoing the final string, but that didn't do the trick. It's weird. At any rate, the other thing I'm having trouble with is preloading the children. If anyone can see why the children are not being pre-loaded from this code, let me know! I've gone through the docs, and it's still not working. I want to preload children so if a parent node is clicked, all children are selected as well (this is accomplished by the listener).

var tree = new Ext.tree.TreePanel
height: 300,
width: 400,
frame: false,
containerScroll: true,
rootVisible: false,
useArrows: true,
loader: (new Ext.tree.TreeLoader
dataUrl: 'json_object_group_list.php',
nodeType: 'async',
checkchange: function(n, checked)
child.fireEvent('checkchange', child, checked);