Ajax programming: Five tips for getting started

The first steps in Ajax programming should be small ones, most experts agree. Here are five tips for introducing Ajax into your Web applications.

Whether Ajax programming spells the end of the traditional Web application as we know it, or merely offers a way

to enhance those apps, it is safe to say the technology is not going anywhere.

More on Ajax programming
Ajax programming: The what, how and when examines where Ajax development has come in the year since the term has been coined, how and where Ajax should grow and what type of UI does, and does not, work with the technology.

Most experts, whether they focus on .NET or Java, commercial products or open-source endeavors, agree that the best step forward with Ajax is a small one.

SearchVB.com recently asked Eric Pascarello, co-author of the book Ajax in Action and an expert on both .NET and JavaScript, what developers should take into consideration when they want to commence Ajax programming. Pascarello offered five tips.

Start small, then review your progress. Rather than conducting a complete Ajax overhaul of your app, Pascarello said, "Start with a double combo or an AutoComplete component and work your way up from there. That will give you a good feel on how your users handle the changes and also gives the rest of the developers on your team time to learn the new architecture."

Don't always rely on the server. If users get chunks of data from the server that do not need refreshing, then build your app so that static data caches on the client, Pascarello recommended. To do this right, you'll have to test your app on a variety of security levels, browsers and operating systems, he added.

Make sure the server can handle the load. Single Ajax refreshes are smaller than the typical http refresh, but if dozens of users are performing the same function, that's a lot of pressure on the server. As an example, Pascarello cited 100 users typing 10-letter words into an AutoComplete field. "[T]hat can be 1,000 requests in a short period of time," he said. "Just because it is [a] small [request] doesn't mean it still cannot cause the server to come to a crashing halt."

Let users know something is happening. With Ajax, application refreshes are silent -- a page's URL does not change once the information has been updated. As a result, users expecting a new URL, as they would see in an app making a full http request, are liable to click a button or icon several times, convinced that will bring about the intended result faster. Users need a visual cue that the refresh is in progress, Pascarelo said. "It can be as simple as a line of text or a loading image," he said.

Above all, know how Ajax programming works. The "x" in Ajax stands for XMLHttpRequest, which lets a Web app send http requests to the server without refreshing an entire Web page. That, combined with DHTML, gives Ajax its rich GUI capabilities. "See how it works at the basic level. Without the basic knowledge of this, you cannot architect a good solution," Pascarello said.

A good starting point in a developer's Ajax programming education effort is our Ajax Learning Guide. This resource offers a variety of articles and tutorials about Ajax, including Atlas, Microsoft's upcoming tool for blending Ajax and ASP.NET technology.

This was first published in May 2006

Dig deeper on ASP.NET and Ajax development

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close