Log inskip to content

Archive for August 19th, 2008

9 AJAX Tips & Tricks

Tuesday, August 19th, 2008

1. Use an AJAX Loader

A simple AJAX loader can take care of a lot of the mishaps that can happen during the client/server communication. Find one you like and stick with it. Take a look at this AJAX load XML file script.

2. GZip Your Data

If you have a lot of data, load times can become a problem. Using compression to reduce the size of the data transferred will reduce download times and increase load times.  Take a look at the PHP GZip Manual Page for GZip usage with PHP.

3. Plan, Plan, and Plan Some More

You’ll save yourself a lot of time by planning ahead. Focus on keeping your functions simple and lightweight.  A good planning phase can take a lot of the headaches out of your development.

4. Pick a Standard Format

Communication to/from the server is essential with all AJAX development. Research the various formats and choose the one that fits your needs. The following are some of the more common formats:
XML
HTML
XHTML
JSON
UED

5. Validate Your Input

AJAX allows us to do real time client side validation against the server.  Having the power of server side validation in real time saves the end user a lot of time and frustration.  Greg Murray wrote a great article on validating form input in real time, definitely worth a read .

6. Server Side Validation - A Must

Client side validation should never be trusted. Once your data hits the server, treat it as if there was no client side validation at all.

7. Keep Sensitive Information on SSL

Just like with standard Web Forms, sensitive information transfered by your AJAX forms should be sent and received through SSL.  If you need help take a look at this article on Securing AJAX.

8. Frameworks

There are a TON of them out there, some good, some bad, and some ugly. They definitely make things easier, but are not always necessary. If your application is simple, keep it lightweight and avoid using a pre-packaged Framework. If you can get away with a small amount of script and still get the job done, go for it!
Here are some of the more popular frameworks (server side and client side):

Javascript

jMaki
Dojo Toolkit
Prototype
Yahoo! UI Library

C++

Wt

.NET

Microsoft AJAX Library

PHP

Sajax
Tigermouse
Xajax

9. Get Version One Out

I can never stress this enough (with any project), get v1 out first! Save all those great ideas that may pop in your head during the development phase for version 2 and beyond. If you didn’t put it in your planning stages, keep it out of your development phase.

Categories