jquery - How to get xml data

后端 未结 2 1111
一个人的身影
一个人的身影 2021-02-19 03:05

Im a total noob to html, css, javascript, and programming altogether. Please bear with me.

Im trying to populate my table using jquery. The data will be coming from an x

2条回答
  •  伪装坚强ぢ
    2021-02-19 03:33

    The sample XML:

    
        
         
          My Cool Book Title
        The my cool book is possibly the best cool book in that any developer could use to     be a great web designer.
        12/1/2010
        
        
         Another PHP book
        Learn everything about PHP with 'Another PHP book,' your ultimate guide to the ins and outs of PHP.
        4/1/2010
        
        
        jQuery Techniques
        jQuery techniques runs you through real life examples of jQuery from beginner to expert
         6/2/2010
         
         
        MySQL Database Book
        Brush up your knowledge with the best MySQL database book on the market.          
        14/2/2010
        
        
    

    And the HTML & jquery.

    $(document).ready(function () {
    $.ajax({
        type: "GET",
        url: "books.xml",
        dataType: "xml",
        success: xmlParser
       });
    });
    
    function xmlParser(xml) {
    
    $('#load').fadeOut();
    
    $(xml).find("Book").each(function () {
    
        $(".main").append('
    ' + $(this).find("Title").text() + '
    ' + $(this).find("Description").text() + '
    Published ' + $(this).find("Date").text() + '
    '); $(".book").fadeIn(1000); }); }

    you can go through the example and you will get idea about the same

提交回复
热议问题