Discussion about Geoff Peters' Presentation, AJAX and PHP - A Winning Combination

Question (from Bruno) (November 14th 2005):

I might have misunderstood your example of the autotyper. It works well as long as I click on submit. Using AJAX concept, isn't it supposed to work without having to click submit? 

Also, would you know the advantages / disadvantages between AJAX and Macromedia Flex outside of the main languages used (PHP vs Action)?

Answer from Geoff (November 22nd 2005):

Hi Bruno,

You're right in saying that the Autotyper doesn't illustrate the "Asynchronous" part about AJAX. The start page of the Autotyper is just a plain CGI form. But once you get into the Autotyper it does use the Javascript XMLHttpRequest object (but synchronously!) and is a good example of how a plain CGI-form PHP application can be speeded up, by using Javascript and XMLHttpRequest.

In the non-AJAX version, every time someone clicked on a new suggested word, it would have to reload the entire page in the browser, which added a couple of seconds of wait time per click. Now it only transfers the minimum amount of data to/from the server that is needed to update the page.

Regarding your other question, I found an interesting article on Flex here:

http://www.digital-web.com/articles/macromedia_flex_and_flex_builder/

The article points out that Flex (which uses Java on the server side) is a proprietary technology that is provided by Macromedia, which has a somewhat less than stellar track record for server-side / enterprise products. If I had a choice I would much rather use PHP for the server side code, because it is an open source technology that is supported by a responsive developer community. Documentation is much better for PHP as well ( http://www.php.net seems to be the one of the best documentation resources for any language I have ever seen). I have found PHP to be one of the easiest languages to learn and use because of this.

PHP is free whereas Flex costs quite a bit ($12,000 for two CPU's).

For the client side, Flash is better if you are doing animations or cool effects, but is more cumbersome for communicating with the server than AJAX. It is even possible to generate Flash applications with PHP using the Ming library, but from experience I don't really recommend this. (For a project I used Ming/Flash to communicate with server-side Perl code on http://www.songtapper.com) Debugging Flash applications is more difficult than debugging Javascript, at least in my experience.

With AJAX/Javascript you need to worry about possible browser differences, and always retest your code when new browsers come out. But that is part of the fun! :)

Hope this helps.

Geoff


Please send your questions or comments to Geoff Peters at gpeters@sfu.ca.

Back to: Article, AJAX and PHP - A Winning Combination