SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Member
    Join Date
    May 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question The Menu Example of HTML_AJAX can not work(urgent!!!!)

    Hi,

    I am one beginner of using HTML_AJAX. I tried the Demo on the below web page:
    http://wiki.bluga.net/index.php?area...&page=Examples

    For the first example "Hello World Demo", it worked after I changed the upper
    case issue in PHP5.

    But for the second example "Menu Demo", I tried all kinds of methodes(including changing upper case), but It can not still work. When I load the
    demo as below webpage:
    http://htmlajax.org/materials/HTML_A...n/MenuExample/
    I found one JAVASCRIPT reporting "Error: Object doesn't support this action"

    Then I downloaded the whole source code and change the file "controller.php" as below:
    PHP Code:
    <?php
    require_once 'HTML/AJAX/Server.php';

    class 
    AutoServer extends HTML_AJAX_Server {
        
    // this flag must be set for your init methods to be used
        
    var $initMethods true;

        
    // init method for my hello world class
        
    function initMenuExample() {
            require_once 
    'MenuExample.class.php';
            
    $menu = new MenuExample();
            
    $this->registerClass($menu'menuexample');
        }

    }

    $server = new AutoServer();
    $server->handleRequest();
    ?>
    Besides this, I also added one "php" tag at the front of the file "MenuExample.class.php", which should be one missing tag from my perspective.
    The old:
    PHP Code:
    <?
    class MenuExample
    .....
    ?>
    My change:
    PHP Code:
    <?php
    class MenuExample
    .....
    ?>
    After this update, no error occurs on the webpage, but the Demo does not still work.
    I got the source code from below:
    http://htmlajax.org/materials/HTML_A...esentation.zip

    Thanks in advance!
    Yu
    Last edited by yustao; Jul 2, 2006 at 06:30.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,036
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    short tags

    If the source is using "short tags", the "<?", instead of "<?php", you should go through the source and fix all the short tags. If the PHP server doesn't have short tags enabled (which could cause problems with xml if it was), this would be for the best. even if a bit tedious.

  3. #3
    SitePoint Member
    Join Date
    May 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mittineague,

    You are right, I have checked all the files. But I think it is not the root cause.
    Would you give me further help to make the exampe work?

    Thanks,
    Yu

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,036
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    files - paths

    You have both of these files and the paths are correct?
    HTML Code:
    <script type="text/javascript" src="controller.php?client=all&stub=MenuExample"></script>
    <script type="text/javascript" src="menuhandler.js"></script>

  5. #5
    SitePoint Member
    Join Date
    May 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I have changed the part you mentioned, but It still does not work. Would you and any other people can download the code to have a try?

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,036
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    trouble shooting

    It's not likely that the script library is shipping with a broken example. I do have PEAR, but the easiest thing would be for you to post a link to the page. Did the error message you posted "Error: Object doesn't support this action" give a line number or more details? (The Firefox, Opera, and Netscape "consoles" give more detail than IE).

  7. #7
    SitePoint Member
    Join Date
    May 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mittineague,

    Sorry for my unclear description. I mean the webpage has the full source codes of the example, include MenuExample Class, auto_server, Javascript and index.php.
    So long we installed the HTML_AJAX library, the example can be executed.

    Thanks again,
    Yu

  8. #8
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,036
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    case mismatch

    Well, I downloaded the Menu Example zip and took a look at it. Seems to me that example code shouldn't have bugs (I'll force myself to not go into a rant), but besides the short tag (which may or may not cause problems depending on the server config) the class is MenuExample but the script wants a new menuexample. Change this so the case matches MenuExample and you won't get the "undefined" error.

  9. #9
    SitePoint Member
    Join Date
    May 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mittineague,

    Yes, you are right. After the change as you did, no error reported, but there is still no contents in the two <select>...</select> tags, which is my true concern.

    Thanks for your nice help.

    Yu

  10. #10
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,036
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    Menu Example

    I uploaded 4 files to the same folder. controller.php, index.html, MenuExample.class.php, and menuhandler.js
    In controller.php I added
    PHP Code:
    ini_set(
        
    'include_path'ini_get('include_path') . ":" .
            
    $_SERVER['DOCUMENT_ROOT'] . "/path_to/PEAR/"); 
    In index.html I change the case to
    HTML Code:
    var remote = new MenuExample(callbacks);
    In MenuExample.class.php I changed the short tag to <?php This is the file where the menu contents are. Personally, I don't know why you would put hard coded values into a class file, but .....
    Anyway it works OK now for me - http:www.mittineague.com/test/index.html
    Are you using all 4 files from the MenuExample zip? (NOT any from the HelloWorld zip)

  11. #11
    SitePoint Member
    Join Date
    May 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, I just tried your page, but there is no contents in the two select tags.
    And, at the left-bottom of the page, there is one error indication.

  12. #12
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,036
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    more bugs

    I only tested in Firefox, which it does work in. It also works in Opera. But you're right, it doesn't work in IE. View source shows IE reading the byte code differently for some reason. I trhink it may have something to do with serializing. I'll have to puzzle some more about this one.
    From http://wiki.bluga.net/index.php?area...&page=Faq#toc5
    What Browsers does HTML_AJAX work with?

    As of 0.3.0, all the examples that ship with HTML_AJAX have been verified to work with

    * Firefox 1.0+
    * Internet Explorer 5.5+ (5.0 should work but it hasn't been tested)

    Most things work with

    * Safari 2+
    * Opera 8.5+
    This may be true of HTML_AJAX, but clearly this is NOT correct when talking about this script that depends upon HTML_AJAX.

  13. #13
    SitePoint Member
    Join Date
    May 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just tested your page in the newest version of Firfox, it does not work neither.
    When I select one option from the select tag, may prompt windows occurs.

  14. #14
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,036
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    test pagIf thm i

    Sorry, that's a test file that I put a bunch of "alert - where am I, what's the var val"s in. The section of script (with a debug alert added)
    HTML Code:
    .......
    if( typeof(menu) == "object" ){
    		for( var key in menu.options ){
    alert("empty func menu.options[" + key + "]");
    			menu.options[key] = null;
    			menu.remove(key);
    		}
    	}
    .......
    Firefox gives key values of "item", "namedItem", and "sellectedIndex".
    But IE gives "language", and "scrollHeight" and then it errors.
    I looked a bit into the HTML AJAX package files. Unfortunately it uses poorly written code. ie.
    eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 x=6(){7 1D="2.0.2";7 C=/\\s*,\\s*/;7 x=6(s,A){33{7 m=[];7 u=1z.32.2c&&!A;7 b=(A)?(A.31==22)?A:[A]:[1g];7 1E=18(s).1l(C),i;9(i=0;i<1E.y;i++){s=1y(1E[i]);8(U&&s.Z(0,3).2b("")==" *#"){s=s.Zess(2);A=24([],b,s[1])}1A A=b;7 j=0,t,f,a,c="";H(j<s.y){t=s[j++];f=s[j++];c+=t+f;a="";8(s[j]=="("){H(s[j++]!=")")a+=s[j];a=a.Z(0,-1);c+="("+a+")"}A=(u&&V[c])?V[c]:21(A,t,f,a);8(u)V[c]=A}m=m.30(A)}2a x.2d;5 m}2Z(e){x.2d=e;5[]}};x.1Z=6(){5"6 x() {\\n [1D "+1D+"]\\n}"};7 V={};x.2c=L;x.2Y=6(s){8(s){s=1y(s).2b("");2a V[s]}1A V={}};7 29={};7 19=L;x.15=6(n,s){8(19)1i("s="+1U(s));29[n]=12 s()};x.2X=6(c){5 c?1i(c):o};7 D={};7 h={};7 q={P:/\\[([\\w-]+(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\]]*)\\]/};7 T=[];D[" "]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=X(f[i],t,n);9(j=0;(e=s[j]);j++){8(M(e)&&14(e,n))r.z(e)}}};D["#"]=6(r,f,i){7 e,j;9(j=0;(e=f[j]);j++)8(e.B==i)r.z(e)};D["."]=6(r,f,c){c=12 1t("(^|\\\\s)"+c+"(\\\\s|$)");7 e,i;9(i=0;(e=f[i]);i++)8(c.l(e.1V))r.z(e)};D[":"]=6(r,f,p,a){7 t=h[p],e,i;8(t)9(i=0;(e=f[i]);i++)8(t(e,a))r.z(e)};h["2W"]=6(e){7 d=Q(e);8(d.1C)9(7 i=0;i<d.1C.y;i++){8(d.1C[i]==e)5 K}};h["2V"]=6(e){};7 M=6(e){5(e&&e.1c==1&&e.1f!="!")?e:23};7 16=6(
    If the problem is in that mess I don't have the time or inclination to debug it. But I may try a few util var dumps when I get the chance. (I'm mod-ing my forum)

  15. #15
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,036
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    HTML AJAX package

    I've contacted one of the package maintainers, Laurent Yaish. Hopefully he will be familiar enough with the code to fix it easily.

  16. #16
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,036
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    bug fix

    I got the impression thought he thought this was my code, but his suggestion fixed it.
    replacing the loop in _emptyMenuItems by menu.length = 0 fixed it.
    so replace this:
    for( var key in menu.options )
    {
    menu.options[key] = null;
    menu.remove (key);
    }

    by
    menu.length = 0;

    This is how I usually clear a select drop down.
    Let me know if it worked for you.

    Thanks,

    Laurent


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •