Ajax, short for Asynchronous JavaScript and XML, is a group of interrelated web development techniques used to create interactive web applications or rich internet applications. Ajax enables web developers to get and post information or data asynchronously to a web server without interrupting the user. Data is sent and received using an XMLHttpRequest object that is supported by most, if not all, modern browsers. Ajax eliminates the traditional full-page post back and provides a better experience for the user by only updating the content or section of the web page that needs to be updated.
Ajax combines many programming tools such as JavaScript, which must be enabled on the client browser in order to utilize any Ajax functionality. A typical use of Ajax technology is to facilitate auto complete for a search box. If you’ve visited ebay.com recently you would’ve noticed that, as you type in the search box, suggestions appear that match actual item names of listings. The webpage never reloads and you’re not interrupted. The search started before you clicked on the search button, making it interactive, responsive and user friendly.
Ajax has many advantages and there are many reasons why you would want to use it. Below are a few of the advantages/examples:
- More interactive and responsive UI. As seen with the ebay example.
- Only content to be updated is requested and transferred. If the entire web page reloads, requests are made by the browser to the web server to get all the necessary information to render to page. This includes html, images, style sheets, JavaScript files and so forth. Ajax focuses the data request and transportation to just the necessary part of the page to be updated using less network bandwidth and reducing the load time of the page.
- Reduced connections to the web server. The web server handles and serves fewer requests since unnecessary images and sheet styles are not requested with every page update.
- Load delayed content. A page can display different content based on the user’s actions. It is not necessary to load that content with the initial page load. Ajax can be used to dynamically get and store that content only if and when needed.
- Auto save user information. Ajax can be used to save partial data similar to Microsoft Word auto save feature.
Ajax technology has been around for quite some time though in recent years its usage and popularity has increased. Java applets, Adobe Flash and Microsoft Silverlight are browser plug-ins that provides similar functionality. While there are numerous reasons to use Ajax technology on your website, you should consider your needs and whether it’s right for you. Ajax requests do not automatically register themselves with the browser’s history and therefore the back button will not revert to the previous state of the page, but rather the previous page. It’s difficult to bookmark a particular state of a web application using Ajax, as bookmarks are URL based. Also, remember that Ajax uses JavaScript, which isn’t executed by web crawlers or spiders, so content retrieved by Ajax will not be indexed by spiders. Mobile browsers found in cell phones and PDAs may not support JavaScript making your application useless in the mobile world. The down side of using Ajax poses a challenge for web developers, and workarounds, such as using the hash (#) symbol in URLs to maintain application state, are the responsibility of the developer.
Ajax can bring a wealth of benefits and improvements to your website and is seen in many Web 2.0 applications. Whether you’re upgrading or redesigning your current site or building a new site, you should definitely consider using Ajax.