When To Use Ajax
AJAX is a web development technique for creating interactive web applications. Ajax applications are mostly executed on the user's computer; they can perform a number of tasks without their performance being limited by the network. This permits the development of interactive applications, in particular reactive and rich graphic user interfaces. Jesse James Garrett of Adaptive Path is generally credited with popularizing the term "Ajax" as a result of his seminal essay on the technology.That article introduces the concepts and establishes that the Ajax approach can work well, but it does tend to leave people with the impression that Ajax can solve every problem, and that just isn't the case.
The biggest problem with applications that use Ajax is that the URL never changes. In Google Maps, for example, there is a "Link to this page" function to get around this problem. It takes careful planning to know when to use Ajax and when to just link to a new URL.
How To Use Ajax
The problem facing me happened to involve a heavily-customized version of a popular blogging system, but only three very minor bits actually have anything to do with that. More importantly, I needed to implement a concurrency control system so that multiple editors couldn't edit the same article and overwrite changes from each other.
In this case study, I want to ensure that only one person at a time has the right to edit a given article. I could issue a database call at page-load to see if anybody else has it locked, or to lock it myself, but how would I know when a user is done editing the page? If the user navigates away from the page, how can I let the database know? I can't refresh the entire page at a regular interval, because editing changes would be lost. I need to be able to constantly let the server know that the user is still actively editing an article, and when that regular update stops, then I'll know that the user has moved on. The only URL will be an internal URL which never needs to be bookmarked, so there are no worries there!