Where should I use Ajax?

Ajax was originally an acronym for asynchronous JavaScript and XML. “Asynchronous” means that multiple events occur independently of each other. Once the client initiates an Ajax callback to the server, the client doesn’t have to wait for a response and can continue to use the web application while the request is being processed. The server will then send the response back to the client, and the client will process it as needed.

What improvements have been made to Ajax?
JavaScript is a client-side programming language, and XML is a markup language for defining data. JSON is another markup language for defining data. JSON (which stands for JavaScript objects) is much easier to use with JavaScript than it is with XML. When it comes to Ajax and JavaScript, JSON web services replace XML web services.

Another major advancement in JavaScript and Ajax is a JavaScript object library called jQuery. This free and open-source software is a JavaScript shell. jQuery is used to simply write client-side JavaScript to navigate and control a page, as well as to make asynchronous Ajax callbacks.

Using jQuery and JSON web services, Ajax callbacks have become standard programming practice for web application design and development.

The Ajax Control Toolkit is a set of controls created by Microsoft that are integrated into Visual Studio and can be dragged into web forms just like html and server-side controls. These controls are designed to be used for Ajax callbacks. However, they can also be used as normal client and/or server controls. For example, Asp.Net does not come with tab controls. However, the Ajax Control Toolkit does. The Tab control can perform a backward transfer to the server in the same way that server controls do.

Ajax should be used anywhere in a web application where small amounts of information can be saved or retrieved from the server without sending the entire pages. A good example of this is checking data when saving. Another example would be changing values in a drop-down list based on other input, such as state and college lists. When the user selects a state, the college list field is again populated only with colleges and universities in that state.

Another great example is when the client needs to save or retrieve session values from the server based on user preferences such as height, width, or object position. Adjusting the width can cause the server to call back to set the session variable for the new width. Thus, whenever the page is updated, the server can adjust the object’s width based on this session variable. Otherwise, the object will revert to the original default width.

Other features include text prompts and autofill text fields. The client enters a pair of letters, and a list of all values beginning with those letters appears below. A callback is made to the web service that retrieves all the values beginning with those characters. This is a fantastic feature that wouldn’t be possible without Ajax, and it’s also part of the Ajax Control Toolkit.

Segue recently used Ajax to support a client application that was having problems due to limited bandwidth and page size. The combination caused the application to take too long to retrieve the data and display it on the page. Sometimes the web server just didn’t have the resources to handle the request and time out. The best solution to this problem was Ajax.

To solve this problem, we created JSON web services on the web server to retrieve information about the selected item. The JSON web service would retrieve the data, convert it to JSON, and return the JSON string. Instead of sending it back to the server, the client will call the web service when it selects an item from the list. We used jQuery to make an asynchronous Ajax call to the web service. After the client received the data back from the web service, additional processing was performed on the client side to display the information on the page. The time it took to display the information on the page after selecting the item was instantaneous. There was no page flickering, refreshing, or backtracking.