Microsoft AJAX Library Tutorial: AJAX with ASP.NET Example

Server wants to know your name:

AJAX Exercise explanations

This is the quickstart example from Chapter 1 of Microsoft AJAX Library Essentials: JavaScript in ASP.NET AJAX 1.0 Explained.

Quickstart is a simple AJAX form validation where the user is requested to write his or her name, and the server keeps verifying if it recognizes the typed name while the user is writing.

While the user is typing, the server is being called asynchronously, at regular intervals, to validate the current user input. The server is called automatically, approximately once per second, which explains why we don't need a button (such as a Send button) to notify when we're done typing. (This method may not be appropriate for real log-in mechanisms but it's very good to demonstrate the basic AJAX functionality.) Depending on the entered name, the message from the server may differ. The process is described by the following diagram:

AJAX Diagram

Steps 1 through 5 are a typical HTTP request. After making the request, the user needs to wait until the page gets loaded. With typical (non-AJAX) web applications, such a page reload happens every time the client needs to get new data from the server.

Steps 5 through 9 demonstrate an AJAX-type call—more specifically, a sequence of asynchronous HTTP requests. The server is accessed in the background using the XMLHttpRequest object. During this period the user can continue to use the page normally, as if it was a normal desktop application. No page refresh or reload is experienced in order to retrieve data from the server and update the web page with that data.

Implement the exercise step by step and find detailed explanations in our book, Microsoft AJAX Library Essentials: JavaScript in ASP.NET AJAX 1.0 Explained .