AJAX Example code showing XML response in a DIV tag

Here is the example code which demonstrates how we can show the response from a XML file to the DIV tag. 
 
Contents of MyPage.html are like below.
 


Using responseText with innerHTML
 

 

   

                        onclick="startRequest();"/>
   

   


 
Notice the line in Javascript.
 
document.getElementById("results").innerHTML = xmlHttp.responseText;
 
 This is doing all the magic for you.
 
Contents of reponse.xml
 

   
       
           
           
           
       
       
           
           
           
       
       
           
           
           
       
       
           
           
           
       
   
My NameLocationAge
JohnNH20
PeterCA25
HaryNC33
 
Keep both the files in the same directory on server and run it.
 


AJAX Example code, AJAX response in DIV, AJAX showing response in DIV, USe AJAX to populate DIV, AJAX XML response, display AJAX result in DIV