Question

Last.fm seems to put # symbols in front of some of their variable names for it's JSON API. Have a look at a sample response here. As soon as I try and access #text with JavaScript I get an invalid symbol error in the console. Any quick fixes or reasons for this hash?

Was it helpful?

Solution

jQuery is only used to retrieve the data. Accessing the #text data is done through straight JavaScript syntax, something like data.recenttracks.track.artist["#text"]

You can't do artist.#text , because # is an invalid first character symbol to be used for accessing an object member. Use the square brackets instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top