File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Ajax.Updater not displaying Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajax.Updater not displaying" Watch "Ajax.Updater not displaying" New topic
Author

Ajax.Updater not displaying

Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
Hi,

I don't have a lot of experience with Ajax. Updater and I'm having trouble getting it to work.
I have a web application with select boxes for building, floor and room. When I select a building I want the appropriate floors to display in the floor select box. Similarly for rooms.
I have used Firebug to debug this and the Response statement is correct.
The problem is it is not displayed on the screen (the web page doesn't change).

My building_select.html:



My buildings.tt




My floors.tt



My .js funtion:



It is what expect, but it doesn't make it to the web page.
Any advice would be appreciated.

Thank you!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Use the Firebug DOM inspector to see what the DOM structure is after the response is returned. From just a limited glance at your code I suspect that you may be trying to shove a select inside another.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
Thanks for your reply.
I did use the DOM Inspector and I don't see anything wrong, but the floor select box shows no floors:



Al
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Shouldn't you be passing in the div id and not the select id to be updated?

Eric
Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
I thought I was:

<div id="divId_floor">

new Ajax.Updater('divId_floor', self_url, {parameters: 'rm=floors&building_seq='+buildingSeq, asynchronous: true});

I'm sorry, it must be something really obvious.
I just don't see it...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Is the DOM inspector showing the valid DOM structure that you are expecting?
Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
The DOM shows no change in the div where the data is supposed to be inserted.
The same empty floor select box.
Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
This is what the DOM shows for the floor div:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Originally posted by Al Gateway:
The DOM shows no change in the div where the data is supposed to be inserted.
The same empty floor select box.

So Prototype isn't doing the update at all from the response?
Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
Yes, Prototype is not updating at all.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Can you create sample files that show this issue with the smallest footprint (and without .tt files). I could give things a try locally and maybe shake something loose.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Are you cached? Clear the cache and see if it works.

Eric
Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
This is part of a bigger web application written in Perl and that uses CGI::Aplication and Template Toolkit.
So there is no issue with the cache.

Bear Bibeault, I'm not sure what kind of files you need.
I already posted the code that relates to the Ajax issues.
There is also Perl code that reads a database and feeds the .tt (template toolkit) files.
But I that code is working, for example I back get the floors for a certain building, as it can bee seen from the server Response.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

If you want people to help, you need to be able to provide reproducible cases. Expecting people to set up Perl and tt just to help you is not all that reasonable. What I was asking for was a raw HTML and JS test case that demonstrates your problem that can be run locally for testing. Without that, only thought inspections can take place.

This is not a wasted exercise. In addition to making it possible for others to run the test case, I've often found that the act of trying to set up a minimal test case to reproduce the problem often results in unearthing the original problem itself.
[ May 06, 2008: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Originally posted by Al Gateway:
This is part of a bigger web application written in Perl and that uses CGI::Aplication and Template Toolkit.
So there is no issue with the cache.
Sorry, not getting that. Just because it's part of a web app using the tools you listed, how does that eliminate the possibility of cache issues?
Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
Sorry, not getting that. Just because it's part of a web app using the tools you listed, how does that eliminate the possibility of cache issues?


Because the application is redrawing a page every time, so I'm guessing caching is not the issue.
However, I did clear the cache and tested, I have the same problem.
Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
If you want people to help, you need to be able to provide reproducible cases. Expecting people to set up Perl and tt just to help you is not all that reasonable. What I was asking for was a raw HTML and JS test case that demonstrates your problem that can be run locally for testing. Without that, only thought inspections can take place.

This is not a wasted exercise. In addition to making it possible for others to run the test case, I've often found that the act of trying to set up a minimal test case to reproduce the problem often results in unearthing the original problem itself.


I understand, I'll try to come up with some files.
Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
Let's try this. I have an html file:



In order_services.js I have:



The URL for Ajax is calling my cgi application but that should just work remotely.
I mean, if you enter https://www1.umn.edu/cgi-bin/do?user=nts&prog=order_services_lim.cgi&rm=flo
ors&building_seq=216 in your browser you should see a select box with the floors for the 216 building.

In the first html file you should change the path to your prototype file.

Please let me know if I'm missing anything.

Thank you!
[ May 08, 2008: Message edited by: Al Gateway ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

One thing I forgot to mention: Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read. Please see this for more information.

You can go back and change your post to add code tags by clicking the .
Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
I just realized that https://www1.umn.edu/cgi-bin/do?user=nts&prog=order_services_lim.cgi is a secure application, so you can't get to it.
So I wrote a small .cgi script that read the building_seq and then prints it:



Then I changed the .html file to call the .cgi script:



This time I put the javascript insertFloors function in the html.
You only need to change the path to prototype.js
However, when I look at my .html file in a browser and select a building, I don't even get a response from the server anymore.
Any help would be greatly appreciated.
[ May 08, 2008: Message edited by: Al Gateway ]
Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
From a previous message it sounds like you might not have Perl installed, but I thought you have to call some sort of script from Ajax.Updater, whether is Perl, or PHP, etc.
I don't know how else to simplify this.
Thanks for trying to help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Ajax can "hit" anything that returns a response. For debug purposes a text file containing the text of a sample response that demonstrates the issue would work just fine.

(Yeah, I have Perl installed, but setting up a CGI environment is more work).
Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
A sample response would be this:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

What version of Prototype? I'll see if I can try to recreate this over the weekend.
Al Gateway
Greenhorn

Joined: May 05, 2008
Posts: 14
1.4.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ajax.Updater not displaying