Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
36
rated 0 times [  43] [ 7]  / answers: 1 / hits: 19001  / 12 Years ago, fri, march 16, 2012, 12:00:00

The current project I'm working on requires me to talk with the windows live API. I use an AJAX request to receive a JSON object with the user details.
How ever I keep getting this error:
Failed to load resource: the server responded with a status of 415 (Unsupported Media Type)



My first idea was to add a &callback=? the url. But then I get Uncaught SyntaxError: Unexpected token : in the JSON response.



I've been searching on how I could fix the error(s). But found no working solution for both errors. On top if that I'm quite unsure which error I should try solving (status 415 or unexpected token). Anything pointing me in the right direction would be greatly appreciated!



$.ajax({
url: https://apis.live.net/v5.0/me?access_token= + localStorage.getItem('Live_token'),
dataType: 'json',
type : 'GET',
contentType: application/json;,
async: false,
success : function(data) {
var id = data.id,
fname = data.last_name,
email = data.emails.preferred;//TODO preferred or account?
alert(id + '|' + fname + '|' + email);
localStorage.setItem('Live_verifier', id + '|' + fname + '|' + email);
},
error : function(data) {
localStorage.removeItem('Live_token');
}
});


thanks in advance


More From » jquery

 Answers
37

Have you tried setting



dataType: 'jsonp',


and the &callback=? in the url? You are calling a server on another domain and so you must set jsonp as dataType


[#86800] Thursday, March 15, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raymondorlandok

Total Points: 530
Total Questions: 110
Total Answers: 96

Location: Lebanon
Member since Wed, Dec 21, 2022
1 Year ago
;