JS using AJAX to dynamically obtain data display from XML files _javascript tips

Source: Internet
Author: User

This article illustrates the way JS uses Ajax to dynamically obtain data display from XML files. Share to everyone for your reference. The specific analysis is as follows:

The following JS code through AJAX to retrieve the content of XML files dynamically displayed to the Web page, the entire page without refreshing

<! DOCTYPE html>  

The contents of the XML file are as follows

<CATALOG> <CD> <title>empire burlesque</title> <artist>bob dylan</artist> < country>usa</country> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <year >1985</YEAR> </CD> <CD> <title>hide your heart</title> <artist>bonnie Tyler </ARTIST> <COUNTRY>UK</COUNTRY> <company>cbs records</company> <PRICE>9.90< /price> <YEAR>1988</YEAR> </CD> <CD> <title>greatest hits</title> <artist >dolly parton</artist> <COUNTRY>USA</COUNTRY> <COMPANY>RCA</COMPANY> <price >9.90</PRICE> <YEAR>1982</YEAR> </CD> <CD> <title>still got the blues</ title> <artist>gary moore</artist> <COUNTRY>UK</COUNTRY> <company>virgin Records </COMPANY> <PRICE>10.20</PRICE> <YEAR>1990</YEAR> </CD> &Lt cd> <TITLE>Eros</TITLE> <artist>eros ramazzotti</artist> <country>eu</country
> <COMPANY>BMG</COMPANY> <PRICE>9.90</PRICE> <YEAR>1997</YEAR> </CD> <CD> <title>one night only</title> <artist>bee gees</artist> <country>uk</
country> <COMPANY>Polydor</COMPANY> <PRICE>10.90</PRICE> <YEAR>1998</YEAR> </CD> <CD> <title>sylvias mother</title> <ARTIST>Dr.Hook</ARTIST> <country >UK</COUNTRY> <COMPANY>CBS</COMPANY> <PRICE>8.10</PRICE> <year>1973</ year> </CD> <CD> <title>maggie may</title> <artist>rod stewart</artist> < country>uk</country> <COMPANY>Pickwick</COMPANY> <PRICE>8.50</PRICE> <year >1990</YEAR> </CD> <CD> <TITLE>Romanza</TITLE> <ARTIST>Andrea bocelli</artist> <COUNTRY>EU</COUNTRY> <COMPANY>Polydor</COMPANY> <price >10.80</PRICE> <YEAR>1996</YEAR> </CD> <CD> <title>when A Man Loves a woman</ title> <artist>percy sledge</artist> <COUNTRY>USA</COUNTRY> <COMPANY>Atlantic< /company> <PRICE>8.70</PRICE> <YEAR>1987</YEAR> </CD> <CD> <TITLE> Black angel</title> <artist>savage rose</artist> <COUNTRY>EU</COUNTRY> <company >Mega</COMPANY> <PRICE>10.90</PRICE> <YEAR>1995</YEAR> </CD> <CD> <
title>1999 Grammy nominees</title> <ARTIST>Many</ARTIST> <COUNTRY>USA</COUNTRY>
<COMPANY>Grammy</COMPANY> <PRICE>10.20</PRICE> <YEAR>1999</YEAR> </CD> <CD> <title>for The good times</title> <artist>kenny Rogers</artist> <COUNTRY>UK</COUNTRY> <company>mucik master</company> <price>8.70</price > <YEAR>1995</YEAR> </CD> <CD> <title>big Willie style</title> <ARTIST> Would smith</artist> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE> 9.90</price> <YEAR>1997</YEAR> </CD> <CD> <title>tupelo honey</title> <
Artist>van morrison</artist> <COUNTRY>UK</COUNTRY> <COMPANY>Polydor</COMPANY> <PRICE>8.20</PRICE> <YEAR>1971</YEAR> </CD> <CD> <title>soulsville</ title> <artist>jorn hoel</artist> <COUNTRY>Norway</COUNTRY> <company>wea</ company> <PRICE>7.90</PRICE> <YEAR>1996</YEAR> </CD> <CD> <title>the Very best of</title> <artist>cat stevens</artist> <country>uk</country> <COMPANY>Island</COMPANY> <PRICE>8.90</PRICE> <YEAR>1990</YEAR> </ cd> <CD> <TITLE>Stop</TITLE> <artist>sam brown</artist> <country>uk</
Country> <company>a and m</company> <PRICE>8.90</PRICE> <YEAR>1988</YEAR> </CD> <CD> <title>bridge of spies</title> <artist>t ' pau</artist> <COUNTRY> uk</country> <COMPANY>Siren</COMPANY> <PRICE>7.90</PRICE> <year>1987</year > </CD> <CD> <title>private dancer</title> <artist>tina turner</artist> < country>uk</country> <COMPANY>Capitol</COMPANY> <PRICE>8.90</PRICE> <YEAR> 1983</year> </CD> <CD> <title>midt om natten</title> <artist>kim larsen</ artist> <COUNTRY>EU</COUNTRY> <COMPANY>Medley</COMPANY> <price>7.80</price> <YEAR>1983</YEAR> </CD> <CD> <title>pavarotti Gala concert</ title> <artist>luciano pavarotti</artist> <COUNTRY>UK</COUNTRY> <company>decca </COMPANY> <PRICE>9.90</PRICE> <YEAR>1991</YEAR> </CD> <CD> <TITLE> The dock of the bay</title> <artist>otis redding</artist> <COUNTRY>USA</COUNTRY> < company>atlantic</company> <PRICE>7.90</PRICE> <YEAR>1987</YEAR> </CD> < cd> <title>picture book</title> <artist>simply red</artist> <COUNTRY>EU</
country> <COMPANY>Elektra</COMPANY> <PRICE>7.20</PRICE> <YEAR>1985</YEAR> </CD> <CD> <TITLE>Red</TITLE> <artist>the communards</artist> <country>uk </COUNTRY> <COMPANY>London</COMPANY> <PRICE>7.80</PRICE> <year>1987</year> </CD> <CD> <title>unchain my heart</title> <artist>joe Cocker </ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>EMI</COMPANY> <price>8.20</price > <YEAR>1987</YEAR> </CD> </CATALOG>


wants this article to help you with your JavaScript programming.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.