'Error getting an element from a web page with Jquery - Access to XMLHttpRequest from origin 'null' has been blocked by CORS policy

I want to get an especific div from a website and embed in my html page like an "iframe", but i want only the graph. I'm using the function "load" with Jquery to do it. I'm new at it and i'm not using a server, just using VSC. When I click the button i receve an error:

Access to XMLHttpRequest at 'https://www.comparadordefundos.com.br/compare/funds/otimo/26673556000132?indicators=ibovespa' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

GET https://www.comparadordefundos.com.br/compare/funds/otimo/26673556000132?indicators=ibovespa net::ERR_FAILED 200

<html lang="pt-br">

<head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
     <script src="https://code.jquery.com/jquery-3.6.0.min.js"
          integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>

     <title>Analise</title>
</head>


<body>

<div id="load">
     <p>test</p>
</div>
<button id="btn">click</button>

<script>
     $(document).ready(function () {
          $("#btn").click(function () {
               $("#load").load("https://www.comparadordefundos.com.br/compare/funds/otimo/26673556000132?indicators=ibovespa #css-gd47iy");
          });

     });
</script>

</body>

</html>



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source