Introduction
ASP.NET page processing model is post back based. That means in order to handle any server side event you must post the form back to the server. This event driven model is certainly powerful and rich but it has drawbacks of its own. Now a days many browsers support client side JavaScript and DHTML. AJAX model is all about making intelligent use of browser's capabilities to give better user experience. In Part 1 of this series I will explain what AJAX is with a simple example.
What is AJAX?
AJAX stands for Asynchronous JavaScript And XML. AJAX by no way is a new technology. The parts of AJAX i.e. HTML, XML, DOM, XMLHTTP and JavaScript are being used for years. AJAX refers to use of these individual pieces together.
Imagine a web form with a TextBox, a Label and a Button. The TextBox is supposed to accept a CustomerID and on the click of the button you are supposed to retrieve the total orders placed by the customer and display in the Label. How will you do it in normal way?
You will write Click event handler for the Button and inside the event handler you will write all the code to retrieve the total orders depending on the CustomerID specified in the TextBox. That means for each and every CustomerID you will cause a post back to the server. Think what will happen if your page contains lots of other controls or heavy images. Naturally the overall network traffic will be much more resulting in a poor performance.
AJAX can solve such problems. Using AJAX you don't cause frequent post backs to the server. Instead you give requests to server side resources (web forms for example) from the client browser itself. Once the request returns the data you update the controls accordingly.
On one hand AJAX can give much better user experience and performance but on the other hand you also need to worry about things such as browsers not supporting JavaScript and cross browser JavaScript.
Read More