<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" >
< Html >
< Head >
< Title > Ajax.html </ Title >
< Meta HTTP-equiv = "Keywords" Content = "Keyword1, keyword2, keyword3" >
< Meta HTTP-equiv = "Description" Content = "This is my page" >
< Meta HTTP-equiv = "Content-Type" Content = "Text/html; charsets = UTF-8" >
<! -- <LINK rel = "stylesheet" type = "text/CSS" href = "./styles.css"> -->
< Script Type = "Text/JavaScript" >
VaR XMLHttpRequest = Null ;
Function Ajaxsubmit (){
If (Window. activexobject ){
XMLHttpRequest = New Activexobject ( " Microsoft. XMLHTTP " );
} Else If (Window. XMLHttpRequest ){
XMLHttpRequest = New XMLHttpRequest ();
}
If ( Null ! = XMLHttpRequest ){
XMLHttpRequest. Open ( " Get " , " Ajaxservlet " , True );
XMLHttpRequest. onreadystatechange = Ajaxcallback;
XMLHttpRequest. Send ( Null ); // Get is set to null, or do not write
}
Function Ajaxcallback (){
If (XMLHttpRequest. readystate = 4 ){
If (XMLHttpRequest. Status = 200 ){
VaR Responsetext = XMLHttpRequest. responsetext;
Document. getelementbyid ( " Div1 " ). Innerhtml = Responsetext;
}
}
}
}
</ Script >
</ Head >
< Body >
< Input Type = "Button" Value = "Get content from server" Onclick = "Ajaxsubmit ();" />
< Div ID = "Div1" > </ Div >
</ Body >
</ Html >