Hey all,

My last function worked well, but it kept the info cached... so i'm
thinking i need to move to .ajax.
When i test one of the values, it comes back as svrSongName =
undefined.  Does the .ajax work differently when you wrap a function
in there?

Thanks for your help again.. you guys have been awesome in hinting me
along thru learning how to use JQuery.


Old Code looked like this:
// Start function when DOM has completely loaded
$(document).ready(function(){
        // Open xml file
        $.get("kprxy.php?proxy_url=http://yp.krushradio.com/getstream.aspx?
stream=stream",{},function(xml){
                // Run the function for each student tag in the XML file
                $('activesong',xml).each(function(i) {
                        svrName = $(this).find("servername").text();
                        svrGenre = $(this).find("servergenre").text();
                        svrSongName = $(this).find("songname").text();
                });
                // Update the DIV called Content Area with the HTML string
                $("#krStreamName").append(svrName);
                $("#krSongPlaying").append(svrSongName);
                $("#krStreamGenre").append(svrGenre);
        });
});


The New Code looks like this:
var svrName;
var svrGenre;
var svrSongName;

$(document).ready(function(){
        // Open the students.xml file
        $.ajax({
                type: "POST",
                URL: "kprxy.php",
                data: "proxy_url=http://yp.krushradio.com/getstream.aspx?
stream=stream",
                success: function(xml){
                // Run the function for each tag in the XML file
                $('activesong',xml).each(function(i) {
                        svrName = $(this).find("servername").text();
                        svrGenre = $(this).find("servergenre").text();
                        svrSongName = $(this).find("songname").text();
                });
                // Update the DIVs
                alert(':' + svrSongName + ':');
                $("#krStreamName").append(svrName);
                $("#krSongPlaying").append(svrSongName);
                $("#krStreamGenre").append(svrGenre);
                }
        });
});

Reply via email to