Home > Article > Web Front-end > Example explanation of XML in AJAX
XML in AJAX is very important, so this article will explain its related knowledge in detail.
Explanation of examples - loadXMLDoc() Function
When the user clicks the "Get CD Information" button above, the loadXMLDoc() function will be executed.
The loadXMLDoc() function creates an XMLHttpRequest object, adds functions that execute when the server response is ready, and sends the request to the server.
When the server response is ready, an HTML table is built, the nodes (elements) are extracted from the XML file, and finally the txtCDInfo placeholder is updated with the HTML table that has been populated with XML data :
function loadXMLDoc(url)
{
var xmlhttp;
var txt,xx,x,i;
if (window.XMLHttpRequest)
{// code for IE7, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
txt="
Title | Artist |
---|---|
The above is the detailed content of Example explanation of XML in AJAX. For more information, please follow other related articles on the PHP Chinese website!