Forum Moderators: phranque

Message Too Old, No Replies

Using AJAX

It's useful, but comes with a learning curve

         

grandpa

5:40 am on Oct 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've run across a couple of good discussions regarding the suite of technological tools called AJAX.

Ajax ideas [webmasterworld.com]

Ajax and AdSense [webmasterworld.com]

Thanks to isorg and Bernard Marx for thier contributions, which helped me hit the ground running. Over the weekend I was toying around and came up with a simple use for this technology on one of my own pages, letting users pick their city (if available) from a drop down list. It's not much more than demo piece, avoiding any real breakthroughs.

There are a few issues I encountered, and so hopefully some of these have already been addressed. First, I cannot validate this page. Maybe I need to use a different dtd? Currently I'm using the HTML 4.01 Transitional DTD. The problem arises with the javascript source. If placed in the head of the document then the javascript fails to select anything from the drop down. To overcome that I placed the source right at the point where it gets used, but at the expense of invalid markup.

Other javascript on the page seems to cause interference. Nothing definite on this point, but specifically having G's AdSense code in between the js source file and the actual drop down list seemed to cause problems with the list. This doesn't make a lot of sense, and may in fact relate to the earlier problem of having the js source in the document head.

CSS styling seems like it will be a big factor in any list oriented use of AJAX. My list drops to show four options, and if there are more than four, the user scrolls thru the list. However, the next line (below city) is for input of State and Zip Code. Right now I have a big ugly 4 line gap between the city and state. I'm pretty sure that with a little CSS magic I can remove this gap.

grandpa

12:16 pm on Oct 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



After a day of thinking about it, and a couple more days of hacking I've nearly come up with something useful.. I had written a web based order entry system for phone and mail orders, and the first step requires customer info.

So far I can type a customer name into the text box, and select from a list matching the typed text. That's pretty slick. I'm cheating a little from that point, because I submit the form to retrieve the customer info from the database and re-display the filled form.

What I've almost been able to complete to to have all the form fields filled in without using the form submit. The best that I've been able to manage is to pre-fill the fields with the customer id (using js) and then as I tab thru each field, the correct value for that field (address, city, state..) will be available from a select option. It's ugly and clumbsy, but I think, a step forward. I'm feeling a bit alone out here, is no one else trying to use this stuff?

rich_b

12:29 pm on Oct 5, 2005 (gmt 0)

10+ Year Member



I'm very interested in using it with PHP on the server side. I haven't jumped in yet though as I'm still trying to work out whether I should use a library like SAJAX or similar and if so, which one.