i want see some game info on steam. I find a api, but when i use it say:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Also, I use json p but it is throw an error:
Uncaught SyntaxError: Unexpected token :
My code is below:
$.ajax({
//crossDomain: 'true',
url: 'http://store.steampowered.com/api/appdetails/?appids=730',
//url: 'http://api.steampowered.com/ISteamApps/GetAppList/v0001/',
//url:'http://store.steampowered.com/api/appdetails/?appids=730',
//url:'games.json',
type: 'get',
dataType:'jsonp',
//dataType:'json',
//data = JSON.parse(data);
crossDomain : true,
success:function(data){
console.log(data);
},
error:function(data){
console.log("Hata ",data);
}
});
I use anyorigin.com but it is not work. When I use local .json file working, but I need steam.
I don't think the URL you have in your example supports JSONP. I see this sort of JSON response:
{
"key": "value"
}
And for JSONP it needs to be:
callback({ key: value })
There might be some confusion here about what JSONP is. JSONP requires the API serve up raw javascript. Not only that, the server must serve up a particular function call in that javascript. JSONP is a hack around cross-origin policies.
edit: As for solution, I would suggest you proxy the JSON through your own server-side application.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.