Jasper
Jasper

Reputation: 23

"XMLHttpRequest cannot load file:///... Preflight response is not successful" error

I'm building a website and the page loads a navbar and some other resources with Jquery .load() function (as seen in code below).

<script>
        $(function () {
            $("#navbar-placeholder").load("subpage_navbar.html");
        });
</script>

When viewing the .html files locally on my computer in safari 5 everything works fine, and it used to work fine in safari 11, but now when I try to open the file I get an error:

XMLHttpRequest cannot load file:///... Preflight response is not successful

Are there any preferences I need to change in safari for this to work like it used to?

Upvotes: 1

Views: 4551

Answers (1)

Ciro Spaciari
Ciro Spaciari

Reputation: 630

XMLHttpRequest dont work with file protocol only with http, data, chrome, chrome-extension, https.

you need to host your file or use something like this link bellow to allow this.

Allow Google Chrome to use XMLHttpRequest to load a URL from a local file

In Safari 11 file protocol access are limited.

[CORS and cross origin access from file:// are now blocked unless Disable Local File Restrictions is selected from the Develop menu.]

Upvotes: 2

Related Questions