0

I am using the jQuery load() method to load some content from different HTML files for organizing purposes, but I am getting this error:

Access to XMLHttpRequest at 'XXXXX' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

My HTML file looks like this:
<!DOCTYPE html>
<html>

<head>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script>
    $(function() {
      $("#Home").load("home.html");
    });
</script>

</head>

<body>

<div id="Home"></div>

</body>
  • 1
    You're loading the page from a local file. You need to go through a webserver in order to use AJAX. – Barmar Jul 15 '20 at 21:16
  • @Barmar is there an other way to load external files? Maybe plain javascript? – uncannyorange Jul 15 '20 at 21:23
  • No, this is a general restriction. You're only allowed to load files from the same domain that the page came from. If you didn't use a server request, there's no "same domain". – Barmar Jul 15 '20 at 21:24

0 Answers0