[英]JavaScript/JQuery access Steam Community Market
I am making a website that needs to get the listings from the steam community market. 我正在制作一个网站,该网站需要从Steam社区市场中获取列表。 I know how to get the JSON, but I'm getting a console error: Uncaught SecurityError: Failed to set the 'domain' property on 'Document': 'https://steamcommunity.com/' is not a suffix of ''.
我知道如何获取JSON,但出现控制台错误: Uncaught SecurityError: Failed to set the 'domain' property on 'Document': 'https://steamcommunity.com/' is not a suffix of ''.
It looks like I set the wrong domain. 好像我设置了错误的域。 Does anyone know the correct domain I need to use? 有人知道我需要使用正确的域吗?
My JavaScript code: 我的JavaScript代码:
<script>
document.domain = "https://steamcommunity.com/";
$(document).ready(function() {
$.getJSON("http://steamcommunity.com/market/priceoverview/?country=US¤cy=1&appid=730&market_hash_name=P90%20%7C%20Asiimov%20%28Factory%20New%29", function(results) {
$("#price").text(results.lowest_price);
});
});
</script>
You can not access the Steam market data with Javascript in the browser because the Steamcommunity servers do not provide the 'Access-Control-Allow-Origin' header in their replies. 您无法在浏览器中使用Javascript访问Steam市场数据,因为Steamcommunity服务器的答复中未提供“ Access-Control-Allow-Origin”标头。
More information about this can also be found with the keyword "CORS". 与此相关的更多信息也可以通过关键字“ CORS”找到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.