AJAX Client Side Step By Step Tutorial - part 3: Document Object Model (DOM) is important side which playing in AJAX. Through DOM interface, javascript can manipulation ( create, modify, parse, etc) XML-like Document, HTML Included.
To see the role of each, please see the example in the following:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>AJAX-Client Side: DOM</title>
<script type="text/javascript">
document.write("< It is created by JavaScript and DOM >");
document.write("<br>");
</script>
</head>
<body>
< It is natural text. >
</body>
</html>
To be cleaner, you can make the separate file Javascript. Create file named "dom.js". Enter following code:
document.write("< It is created by JavaScript and DOM >");
document.write("<br>");
Then, modify you html like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>AJAX-Client Side: DOM</title>
<script type="text/javascript" src="dom.js">
</script>
</head>
<body>
< It is natural text. >
</body>
</html>