Thoughts on AJAX

I’ve done a bit of work with AJAX, usually just for fun, but I think I know enough to talk about it. I’m sure you all know what it does by now, so I don’t need to explain that (here’s a link in case you don’t). I’ll just move on to how I use it.

When I first started using AJAX, I wrote my own functions for it from the ground up. After rewriting them everytime I started a new project I thought it was time to find a good library. I looked around a bit, found Protoype unsuitable, and finally landed upon AjaxRequest. It wasn’t too bloated and seemed to have nice features. What I was really after was the form serialzation, which Prototype has. AjaxRequest has a similar function, but much smaller file size. I think I can get it down to about 8k by removing the comments vs Prototype’s massive 40k. Sure Prototype does other things, but I like to stay small. (I also recently discovered this.)

Another area of interest concerning AJAX is the emergence of JSON, an alternative to XML. It’s native to Javascript and a couple other languages so it has the benefit of speed. But it’s not native to PHP and has to be translated, which takes more time than translating XML so I don’t use it for AJAX. It might help you program better Javascript, though. Really it depends on the situation. You can’t always use JSON, and you can’t always use XML.

Well that’s all for now. I’ve got to get to my Flash/AJAX(!) course.

2 Responses to “Thoughts on AJAX”

  1. apexad

    I use a little AJAX (or something close enough to it) at http://www.restaurantselector.com and it is basically JavaScript, a hidden iFrame, and some PHP. Simple, yet very effective.

    Perform a search, click on a row in the result table.

  2. Chris

    Wow, that’s pretty nifty, apexad. Did you populate the database manually or did you have an existing listing of places?

Leave a Reply