jQuery storing settings

Posted by user138988 on Stack Overflow See other posts from Stack Overflow or by user138988
Published on 2010-04-11T18:12:41Z Indexed on 2010/04/11 18:23 UTC
Read the original article Hit count: 201

Filed under:
|
|

I'm trying to build a player for a radio station that automatically updates the current song from an XML file, the problem is that I don't want it to update the UI (updateSongIMG) unless the song has actually changed. I have a hidden div called settings_songid that stores the song id and it should check that against a value in the XML file, if its different, then it should update it. The problem is that the function below does not actually work, it pulls all the XML data fine, but it doesn't call updateSongIMG as it fails the 'if'.

function loadXML() {
    $.get('player.xml', function(d){
        $(d).find('onair').each(function(){
            var $onair = $(this); 

            var show_name = $onair.find('showname').text();
            var song_l1 = $onair.find('songline1').text(); 
            var song_l2 = $onair.find('songline2').text();  
            var song_img = $onair.find('songimg').text(); 

            var song_id = $onair.find('song_id').text(); 
            var old_song_id = $("#settings_songid").html();

            if (!old_show_id==show_id){
                $("#settings_songid").html(song_id);

                updateSongIMG(song_img,song_l1,song_l2);
            }
        });
    });
};
?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX