AJAX can be used for interactive communication with an XML file.
The Below example will demonstrate how a web page can fetch information from an XML file with AJAX:
When a user selects a CD in the dropdown list above, a function called "showCD()" is executed. The function is triggered by the "onchange" event:
The showCD() function does the following:
The page on the server called by the JavaScript above is a PHP file called "getcd.html".
The PHP script loads an XML document, "demofile.xml", runs a query against the XML file, and returns the result as HTML:
When the CD query is sent from the JavaScript to the PHP page, the following happens:
Your Query was successfully sent!