Agile Ajax

Five Ajax Anti-Patterns

This is an item from back in March, entitled Ajax and XML: Five Ajax anti-patterns. The material isn't rocket science, but every so often it is good to be reminded of how not to do Ajax.

The five anti-patterns are

  1. Polling on a timer when you don't need to
  2. Not inspecting the return results in the callback (of an XHR)
  3. Passing complex XML when HTML would be better
  4. Passing XML when you should pass JavaScript code
  5. Doing too much on the server

A useful warning on the behavior of timers, familiar to most experienced Javascript developers, but useful nonetheless:

The window.setInterval() method tells the page to call back a particular function on a particular interval -- say, every second. Most browsers talk a good game when it comes to these timers, but they rarely deliver, primarily because the JavaScript language is single threaded. If you ask for a second, you might get the callback at 1 second or 1.2 seconds or 9 seconds or any other time.

Give it a read. To be honest, I have seen a number of inappropriate uses of polling on some public web sites, so it may seem like a dope slap obvious kind of thing to me and you, but plenty of people fall for it.


Technorati : , ,

Topics:

Comments: 1 so far

  1. These examples aren’t realistic. Using a timer to check a request or do “search-as-you-type” (or rather, search as time passes by)? Seriously?

    How about his runSort function for an antipattern?

    Comment by Tim Cooijmans, Thursday, May 3, 2007 @ 2:27 am

Leave a comment

Powered by WP Hashcash

About Pathfinder

  • We design and build extraordinary applications for companies looking to make the next great idea a reality.
  • learn more

Topics

WordPress

Comments about this site: info@pathf.com