JQuery HTTP Get Request for Last.fm

I am trying to execute an HTTP Get request using jQuery, but I am getting an empty string as an answer, so I assume that I am doing something wrong. As a guide, I used the documentation from http://api.jquery.com/jQuery.get/ .

My code is as follows

$.get("http://www.last.fm/api/auth/?api_key=xxxkeyxxx", function(data){ window.console.log(data); }); 

Edit: now my code is as follows

 $.getJSON("http://www.last.fm/api/auth/?api_key=c99ddddddd69ace&format=json&callback=?", function(data){ window.console.log(data); }); 

But I get a syntax error [Aborting this error] \ n

And is it at http://www.last.fm/api/auth/?api_key=c99ddddddd69ace&format=json&callback= ?

Last edit: it seems like this is because last.fm responds with html not JSON, any ideas would be appreciated

+7
javascript jquery api
source share
4 answers

last.fm will reply to the login page ... check documents ...

If the user has not logged into Last.fm, they will be redirected to the login page before being asked to grant permission to use the web application to use their account. On this page they will see the name of your application along with the application description and logo as in section 1.

copied from

http://www.last.fm/api/webauth

+1
source

If your script is not sent from www.last.fm , then you will not be able to do this due to the Same Origin Policy restrictions imposed by browsers.

You should investigate request proxying through your server.

+3
source

pkaeding is partially correct - you cannot do it the way you are trying, but last.fm offers a RESTful API with json.

Last.fm API - http://www.last.fm/api/rest

jQuery API - http://api.jquery.com

+1
source

you need to use jsonp iin method to get cross data domain here is an example and thread of whoever does this

+1
source

All Articles