开发者

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',

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜