Monday, July 28, 2008

First Ajax Script

I had a mini-land mark happening recently. I was creating a web page that allowed a user to scroll through images of a photo library. Now normally this wouldn't be that big of a deal because they're just new links/pages. However, this page was different because there is music playing in the background. I couldn't have the entire page refresh because then the song would start all over. Lame.

There are a couple ways to tackle this problem and I decided to try doing it with Ajax. Basically, Ajax allows you to update only parts of a page without reloading the entire thing. It sends a simple command to the server which returns only that part. This has two benefits. First, once the page is loaded, updating information on the page is really fast. Second, it allows for cool visual effects including, like I'm doing, letting things continue to run while other parts change. If you use Gmail, many parts use Ajax.

So I found a good tutorial and followed it. To my surprise, Ajax is extremely easy to use. The cool part about it is that it's not a new language, it's simply a new way of using existing languages (javascript with PHP, Perl, ASP or XML for those keeping score). So, from now on, I'm sure almost all my web pages are going to be using Ajax just like many of my pages currently use javascript and PHP.

No comments:

Post a Comment