Pergunta

I wan't to get a list of songs via the tinysong API which grabs it from Grooveshark I'm doing it via $.ajax and so far i got this:

$.ajax({
    url : 'http://tinysong.com/s/Beethoven?format=json&key='+key,
    type : 'get',
    dataType : 'jsonp',
    succes : function(response){
        console.log(response);
        $('.content').append(response);
    },
    error: function(error){
        console.warn('ERROR');
        console.warn(error);
    }
});

Where key it's the API key they assigned me. I'm getting the following error :

Resource interpreted as Script but transferred with MIME type text/html: "http://tinysong.com/s/Beethoven?format=json&key=HERE_IS_MY_KEY&callback=jQuery172021696692402474582_1344209008518&_=1344209008523".

However if I go to that url I do get the results printed out like so:

[{"Url":"http://tinysong.com/Aoxo","SongID":25802452,"SongName":"Symphony No. 7 in A major, Op. 92: Allegretto","ArtistID":1833,"ArtistName":"Beethoven","AlbumID":4497124,"AlbumName":"Beethoven: 9 Symphonien, Ouvert\u00fcren (1 of 6), Berstein, Leonard"},{"Url":"http://tinysong.com/jh4X","SongID":2909282,"SongName":"Piano Concerto No. 5 in E flat major op. 73 'Emperor'","ArtistID":1833,"ArtistName":"Beethoven","AlbumID":268605,"AlbumName":"The Best Of Beethoven"},{"Url":"http://tinysong.com/JhLy","SongID":31825464,"SongName":"Beethoven: Piano Sonata #23 In F Minor, Op. 57, \"Appassionata\"","ArtistID":1833,"ArtistName":"Beethoven","AlbumID":4913792,"AlbumName":"Beethoven's Greatest Hits"},{"Url":"http://tinysong.com/6Jk1","SongID":4925300,"SongName":"Beethoven #4: Adagio","ArtistID":1833,"ArtistName":"Beethoven","AlbumID":842118,"AlbumName":"Beethoven: Symphonies Nos. 7 & 4"},{"Url":"http://tinysong.com/gGW0","SongID":11896153,"SongName":"F\u00fcr Elise","ArtistID":1833,"ArtistName":"Beethoven","AlbumID":2087629,"AlbumName":"Beethoven and the Sea"}]

How can i get this information passed to my javascript ?

Foi útil?

Solução

The "error" you are getting is only a warning. Tinysong transfers the JSON response with a wrong content type ("text/html"). You can verify this with curl, e.g.:

curl --head http://tinysong.com/s/Beethoven\?format\=json\&key\=<your key>

The explanation why your script is not working and a solution for your problem can found in this answer (please read also the comments).

Maybe you should contact Tinysong, report the bug regarding the content type and ask for JSONP support.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top