xml file

Discussion in 'jQuery' started by ssimon171078, Apr 20, 2015.

  1. #1
    i need to list xml file with JQUERY,i started to write:
    <html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script>
            $(document).ready(function(){
                $.ajax({
                    url: "test.xml",
                    type: "GET",
                    dataType: "xml",
                    success: function (response) { // response – output of PHP script from server
                        $('.results').html(response);
                        console.log("success");
                    },
                    error: function (response) {
                        console.log("failed");
                    }
                });
    
    
    
    
            });
        </script>
    </head>
    <body>
    
    <div id="txtCDInfo">
        <button onclick="loadXMLDoc('test.xml')">Get CD info</button>
    </div>
    
    </body>
    </html>
    
    Code (JavaScript):
    my xml file:

    <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>
    </CATALOG>
     
    ssimon171078, Apr 20, 2015 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    And... was there a question somewhere? And why in the world are you using a loadXMLDoc onclick-event if you're using jQuery anyway? No javascript in the markup, man!
     
    PoPSiCLe, Apr 20, 2015 IP