AJAX is mainly used to build a fast, dynamic website, but also to save resource.
Example
Follow These Steps to build a web applications:
Get a text
Get from XML
Write to body
Post a text
1)Get a Text:
<html>
<head>
<script>
function submitForm()
{
var req = null;
if(window.XMLHttpRequest) req = new XMLHttpRequest();
else
if (window.ActiveXObject) req = new
ActiveXObject(Microsoft.XMLHTTP);
var doc = req.responseXML; // assign the XML file to a var
var element = doc.getElementsByTagName('root').item(0); // read the first element with a dom's method
document.ajax.dyn.value= element.firstChild.data; // assign the content of the element to the form
3)Write to body
In this example, the text read is put in the body of the page, and not into a textfield. The code below replaces the textfield form object and the second part replaces the assignment into the JavaScript function.
<div id="zone">
... some text to replace ...
</div>
In this example, a text is sent to the server and is written to a file. The call to the "open" method changes, the argument is POST method, and the "send" method also has now a value for argument.