当使用jQuery尝试获取Steam用户CS:GO库存时,我在javascript控制台中收到错误:
XMLHttpRequest cannot load http://steamcommunity.com/profiles/76561198093634829/inventory/json/730/2. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://rekit-philipshilling.c9.io' is therefore not allowed access.
我的JavaScript是:
function getSteamInventory() {
if(isLoggedIn()) {
var inventoryJson;
//http://steamcommunity.com/profiles/<STEAMID>/inventory/json/<APPID>/2
$.getJSON('http://steamcommunity.com/profiles/'+ getSteamData().steamid +'/inventory/json/730/2', function(data) {
inventoryJson = data;
});
return inventoryJson;
}
return false;
}
这似乎工作正常,我试图获得JSON的URL工作正常。