Board Logo

JavaScript Error: TREE_ITEMS is Undefined
BaptistKitty - 2/7/2005 at 02:50 PM

I keep getting the error 'JavaScript Error: MENU_ITEMS is Undefined' and I don't understand why. It seems to happen whenever I edit the tree_items.js file but only some times. I figure I must have edited it wrong but I don't know how I could of. What causes that?

Thanks for any help...

tigra - 5/27/2005 at 04:26 AM

Usually this is caused by syntax error in the structure.

slug - 9/15/2005 at 09:04 PM

post the menu if you haven't fixed it by now and have someone looad at it.

matejfn - 8/31/2006 at 07:34 AM

I have the same problem.

BUT it is only IE issue. In Opera and FireFox everything is fine.

I generate TREE_ITEMS with PHP.

<script language='JavaScript' type='text/javascript'><?php echo $ITEMS ?></script>

I get page source in browser: (it works in FF & Opera)

<script language='JavaScript' type='text/javascript'> var TREE_ITEMS = [["test", null]];</script>

If I copy this string from browser page source and post it in my script like:

<script language='JavaScript' type='text/javascript'> var TREE_ITEMS = [["test", null]];</script>

IE works fine.

tigra - 8/31/2006 at 09:28 AM

Looks identical to me so there should be no problem. If there is a problem then look for differences. The browser has no way of knowing if that text was there statically or it's generated.

matejfn - 8/31/2006 at 10:42 AM

I looked for differences in string, but there are no differences. The strings are 100% identical.

I know that browser has no way of knowing that. But is it posible that IE runs function before var TREE_ITEMS is set correctly?

my total code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<script language='JavaScript' type='text/javascript' src="{$prj->dir_js}tree.js"></script>
<script language='JavaScript' type='text/javascript' src="{$prj->dir_js}tree_tpl.js"></script>
<script language='JavaScript' type='text/javascript'>var TREE_ITEMS = [{$tree}];</script>
<script language="JavaScript">
<!-- //
new tree (TREE_ITEMS, TREE_TPL);
// -->

tigra - 8/31/2006 at 10:47 AM

If there is the problem with the IE running the code incorrectly it would appear in both cases. something must be different.

matejfn - 9/4/2006 at 06:23 AM

It was character encoding in borwser.

Data from DB are windows-1250 page was UTF-8 if i copyied string into page it vas OK becous it get same encodin as page.

Now it's working :)


Back to forum: