Jquery ajax: Invalid label
My code:
$.ajax({
url: 'http://tinysong.com/b/Beethoven?format=json&key=<my key..>',
dataType: 'jsonp',
suc开发者_如何转开发cess: function(response) {
console.log(response);
}
});
Firebug says "invalid label". But when i visit the url in my browser, i see:
{"Url":"http:\/\/tinysong.com\/7Wm7","SongID":8815585,"SongName":"Moonlight Sonata","ArtistID":1833,"ArtistName":"Beethoven","AlbumID":258724,"AlbumName":"Beethoven: Piano Sonatas"}
Looks like a corret json-string to me. Am i missing something? Thanks!
That's JSON. You're asking for a JSONp string in the dataType, which would require your output to be wrapped in a function.
Try:
$.getJSON('http://tinysong.com/b/Beethoven?format=json&key=<my key..>&callback=?', function(data){
console.log(data);
});
One possible solution is here. Hovewer, if you are performing request from the same domain, you dont have to use jsonp, so you could replace dataType: 'jsonp',
with dataType: 'json',
精彩评论