How AJAX is like pepper

Don't go completely crazy with AJAX. Use good judgment on how and when to use it.

Last Updated: • Develop •

Since my last post of when to use AJAX,  a lot has changed in the ways of AJAX programming. New tools, ideas, and techniques are constantly being developed to support this latest and greatest craze.

Some developers just want use the latest buzzwords and technologies in their applications just to prove that they can build such a beast. Sort of like an "I climbed Mt. Everest" battle cry.

However, most applications shouldn't be built completely with AJAX from the ground up. Of course, AJAX and DHTML are two completely different animals. But that's another post altogether.

Just a Pinch

AJAX should be used sparingly like pepper on food. Just "sprinkle" it on some applications, don't dump an entire load of AJAX into your application. The more you add to it, the more complex it will become to maintain. Keep it simple and use it with good judgment.

My advice of where to put AJAX or how to learn AJAX?

Write your application with your favorite server model (ASP.NET, PHP, ColdFusion, etc.). Make sure it's functional before you even think of adding AJAX or you'll muddy the waters even more.

Then look your application over. Where would AJAX benefit your users? Here are a couple of suggestions:

  • Do you have an OnChange event on a dropdown list that completely refreshes the page? Instead of refreshing the page, make an AJAX call, return JSON, and fill in the proper fields.
  • Speaking of onChange JavaScript events, do you have cascading dropdowns? This is a perfect case of when to use AJAX. Selecting one item from dropdown A affects the list in dropdown B. Streamlining this process provides a better experience for the user (and they don't forget where they last left off).
  • Have a huge table/grid? Consider using AJAX or one of the many AJAX Frameworks out there. Instead of writing your own, may I recommend the Dojo JavaScript Framework. They just included the newly TurboGrid (UPDATE: sorry, it's been taken down) which is just plain awesome!
  • Waiting for a large page to load? Load the main page and then load the subcomponents through AJAX.

As you keep building web applications, you'll start to see places where AJAX does make sense.

How do you integrate AJAX into your application?

Did you like this content? Show your support by buying me a coffee.

Buy me a coffee  Buy me a coffee
Picture of Jonathan Danylko

Jonathan Danylko is a freelance web architect and avid programmer who has been programming for over 20 years. He has developed various systems in numerous industries including e-commerce, biotechnology, real estate, health, insurance, and utility companies.

When asked what he likes to do in his spare time, he replies, "Programming."

comments powered by Disqus