AJAX Examples

To help you understand AJAX works, we create a small AJAX application:

Examples

使用 AJAX 修改该文本内容




AJAX examples of analysis

The above AJAX application contains a div and a button.

div portion for displaying information from the server. When the button is clicked, it is responsible for calling a function named loadXMLDoc () is:

<!DOCTYPE html>
<html>
<body>

<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>

</body>
</html>

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

<head>
<script>
function loadXMLDoc()
{
/en/en AJAX script goes here /en.
}
</script>
</head>

The following sections will explain your AJAX works.