AJAX Introduction

AJAX is a developer's dream, because you can:

Read data from a web server - after the page has loaded

Update a web page without reloading the page

Send data to a web server - in the background


What is AJAX?

AJAX = Asynchronous JavaScript And XML.

AJAX is a technique for creating fast and dynamic web pages.

AJAX = Asynchronous JavaScript and XML.

AJAX just uses a combination of:

A browser built-in XMLHttpRequest object (to request data from a web server)

JavaScript and HTML DOM (to display or use the data)

AJAX is a misleading name. AJAX applications might use XML to transport data, but it is equally common to transport data as plain text or JSON text.

AJAX allows web pages to be updated asynchronously by exchanging data with a web server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

How AJAX works?

1. User sends a request from the UI and a javascript call goes to XMLHttpRequest object.

2. HTTP Request is sent to the server by XMLHttpRequest object.

3. Server interacts with the database using JSP, PHP, Servlet, ASP.net etc.

4. Data is retrieved.

5. Server sends XML data or JSON data to the XMLHttpRequest callback function.

6. HTML and CSS data is displayed on the browser.