The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> jQuery xml
locoforcoco9
post May 3 2012, 07:14 PM
Post #1





Group: Members
Posts: 6
Joined: 18-January 11
Member No.: 13,624



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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Frederiek
post May 4 2012, 04:51 AM
Post #2


Programming Fanatic
********

Group: Members
Posts: 4,744
Joined: 23-August 06
From: Europe
Member No.: 9



Try searching for "jquery: read xml".
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th March 2015 - 12:15 AM