I am trying to access this JSON feed to get the last item in the feed which is the current song playing on the radio station, so I can push it in to a stream player web app:
function getSongData(){
$.ajax({
url: 'http://cjzn.streamon.fm/metadata/recentevents/CJZN-48k.json',
dataType: 'jsonp',
success: function(data) {
var totalItems = data.length;
alert('Current song: ' + data[totalItems].TIT2);
},
error: function() {
alert('Unable to retrieve data');
}
});
}
As you can see I'm using data.length
to retrieve the total number of items, which would mean that the number is also the last item in the feed. All I can get is the error message! I understand I need to use JSONP to get the data to my domain, but I honestly don't know if JSONP is supported do that could be the culprit. If so, how else do I get the feed data?