jQuery storing settings
- by user138988
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);
}
});
});
};