Help - Search - Members - Calendar
Full Version: jQuery xml
HTMLHelp Forums > Programming > Client-side Scripting
locoforcoco9
Okay, so I have't used jQuery before, and I'm trying to make an XML blurb thing.
It's supposed to read stuff from an XML file, structured as so:
CODE

<blurbs>
  <blurb id="0">
    <title>TITLETEXT</title>
    <body>BODY TEXT<body>
  </blurb>
...
</blurbs>


My jQuery code is:
CODE

$(document).ready(function(){
    $("#descButton").click(function(){
        $("#descText").slideToggle();
    });
    $("#menuTitle").click(function(){
        $("#specMenu").animate({width: 'toggle'});
    });
    $.ajax({
        type: "GET"
         url: "blurb.xml"
         dataType: "xml"
         success: function(xml) {
             var id = Math.floor(Math.random()*6);
             var blurbs = $(xml).find("blurbs");
             var blurb = (blurbs).find("blurb id="+id);
             var title = (blurb).find("title").text();
             var body = (blurb).find("body").text();
             $(title+"<hr style='width:95%' />"+body).appendTo('.blurbs');
         }
    });
});


Thanks for any help. I'll try to respond ASAP
Frederiek
Try searching for "jquery: read xml".
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.