I'm a little new to JSON Syntax.
How can I extract the value of listeners from this JSON array?
I've tried with myvar.track.listeners but it doesn't work.
Can someone point me in the right direction?
The code that I'm using to get that value is:
function getInfo(artista, titolo) {
artista = artista.replace(" ","%20");
titolo = titolo.replace(" ","%20");
$.post("http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=31f2cd3c2530c87e110cc5212166d24c&artist="+artista+"&track="+titolo+"&format=json", {}, function(data) {
$("#listeners").html("<span class=\"span_listeners\">Ascoltatori: "+data.track.listeners+"</span>");
}, "json");
}
track.listenersis correct, but I'm fairly sure you can't name a variablevar. Check your javascript console for errors. A little more context on what you tried would be helpful too.var, that was just to explain what I was doing. However, I just wanted to get that value with jQuery. @xaro Ok.