Easy Tutorial
❮ Ajax Examples Ajax Xmlhttprequest Onreadystatechange ❯

AJAX Example


To help you understand how AJAX works, we have created a small AJAX application:

Example

Modify Text Content Using AJAX


AJAX Example Explained

The AJAX application above includes a div and a button.

The div is used to display information from the server. When the button is clicked, it triggers the function named loadXMLDoc():

<div id="myDiv"><h2>Modify Text Content Using AJAX</h2></div>
<button type="button" onclick="loadXMLDoc()">Modify Content</button>

Next, add a <script> tag in the head section of the page. This tag contains the loadXMLDoc() function:

<head>
<script>
function loadXMLDoc()
{
    .... AJAX script execution ...
}
</script>
</head>

The following sections will explain how AJAX works.

❮ Ajax Examples Ajax Xmlhttprequest Onreadystatechange ❯