1

For some kind of weird reason my JSON requests writes the following HTML.

undefined

undefined

undefined

undefined

undefined

undefined

undefined

undefined

undefined

undefined

undefined

undefined

undefined

undefined

undefined

undefined

undefined

undefined

undefined

Kamaya Painters is a group name used by Dutch artists Tijs Verwest (better known as Tiesto) and Benno De Goeij, from Rank 1. All tracks were released on Black Hole Recordings, and were subsequently licensed to the Planetary Conciousness and Data Records labels. Endless Wave, in 1998, was the first tune to be released by Kamaya Painters and it has been heralded as one of the true trance classics, even though it actually hints towards the similar melody as Liquid Child - Diving Faces. - *I asked for the bio through my script, so this actually works. *

I have written the following jQuery code to call the JSON and write it in my HTML.

$('#artists li a').live('click',function() {



    var artistid = $('img', this).attr('alt');

    $.getJSON("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=" + artistid +            "&api_key=XXXXXXXXXXXXXXXXXXXXXXXXX&format=json&callback=?", function(data) {
                var popupinfohtml = '';
                $.each(data.artist, function(i, item) {      
                console.log(data);   
                popupinfohtml += " <h5> " +item.name+ " </h5><p> " +item.summary+ "</p>";
                });
                $('#moreinfo').html(popupinfohtml);
    }); 
 });

Here's the matching response: http://www.last.fm/api/show/artist.getInfo

Anyone that can help?

Ferrax
  • 35
  • 1
  • 1
  • 3
  • You need to use a debugger in your browser (Like firebug) and put a breakpoint on the line `$.each(data.artist, function(i, item) {` and then examine the `data` variable to see what, exactly you're getting returned. At a guess, the `name` or `summary` properties may be mislabeled in your code (case correct?) or there may be another layer before you reach them - hard to tell without seeing what's in `data` – Basic Jan 08 '13 at 14:54
  • I have console.logged the data numerous times, but I can't seem to figure out what it is. Here's what I get: http://i.imgur.com/sfWoQ.png – Ferrax Jan 08 '13 at 15:03
  • Fixed it! The selector name didn't really exist as I interpreted it, nor did the summary! Thanks for encouraging me to look at it AGAIN. I was kinda blind :-). – Ferrax Jan 08 '13 at 15:10
  • You're welcome, glad I could help a little – Basic Jan 08 '13 at 16:22

1 Answers1

0

As far as I understand the documentation at the link you posted the request returns an XML structure. So appending this to your HTML page will always lead to a strange result, as the browser will just ignore the XML tags like "" or "" and the others.

What is left and thereby shows is the content inside the XML tags.

Good luck. :)

Tom Fink
  • 532
  • 5
  • 17