-1

I am making a website that needs to get the listings from the steam community market. 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 ''. It looks like I set the wrong domain. Does anyone know the correct domain I need to use?

My JavaScript code:

    <script>
        document.domain = "https://steamcommunity.com/";

        $(document).ready(function() {
            $.getJSON("http://steamcommunity.com/market/priceoverview/?country=US&currency=1&appid=730&market_hash_name=P90%20%7C%20Asiimov%20%28Factory%20New%29", function(results) {

                $("#price").text(results.lowest_price);

            });
        });
    </script>
Benjamin Owen
  • 608
  • 2
  • 10
  • 28

1 Answers1

2

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.

More information about this can also be found with the keyword "CORS".

chrki
  • 6,143
  • 6
  • 35
  • 55