I'm trying to make an HTTP Get request using JQuery, but I get an empty string as a response, so I figure I'm doing something wrong. I used the documentation from http://api.jquery.com/jQuery.get/ as a guide.
My code looks like this
$.get("http://www.last.fm/api/auth/?api_key=xxxkeyxxx", function(data){
window.console.log(data);
});
Edit: My code now looks like this
$.getJSON("http://www.last.fm/api/auth/?api_key=c99ddddddd69ace&format=json&callback=?",
function(data){
window.console.log(data);
});
But I'm getting a syntax error [Break on this error] \n
And it's located in http://www.last.fm/api/auth/?api_key=c99ddddddd69ace&format=json&callback=?
Latest edit: It seems this is because last.fm is responding with html not JSON, any ideas would be appreciated
Unless your script is being served 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 proxying the request through your server.
last.fm will respond with login page... check the docs ...
If the user is not logged in to Last.fm, they will be redirected to the login page before being asked to grant your web application permission to use their account. On this page they will see the name of your application, along with the application description and logo as supplied in Section 1.
copied from
http://www.last.fm/api/webauth
pkaeding is partially correct - you wont be able to do this in the way you are attempting, but last.fm does offer a RESTful API with json.
Last.fm API - http://www.last.fm/api/rest
jQuery API - http://api.jquery.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With