Working on a web app that talks to the last.fm API. For some reason, the ajax() function is not returning anything. Even though I see the app trying to talk with the API there's no callback, and even the "always" and "fail" functions fail to run. I've verified that the API key works fine. Not sure what's going on...
Here's the call, simplified for the purposes of this question:
$.ajax({
type: 'GET',
url: 'http://ws.audioscrobbler.com/2.0/',
contentType: "application/json; charset=utf-8",
dataType: 'jsonp',
data: {artist: 'cher', track: 'believe', method: "track.search", api_key: '(my key here)', format: 'json'},
done: function() {
alert('done')
},
fail: function() {
alert('fail')
},
always: function(data) {
alert('always')
try{
var matches = data['results']['trackmatches']['track'][0]
console.log(data)
}
catch(err) {
returned = data['results']['opensearch:Query']['searchTerms']
$('#album-display').find('ul').append(returned + "<br>")
}
}
});