0

For school we have to make a site. That site has to run from a local file by opening the index.html. I am using:

<script type="text/javascript">
$("#navbar").load("SideBar.html");
</script>

To get a sidebar. The problem is that I get the XMLHTTPREQUEST error on Chrome, on safari it works perfectly. The teacher does not allow to use a webserver. What can I do so that my teacher is able to run my site without a webserver?

  • 1
    Why not just put the contents of `SideBar.html` in `#navbar` from the start? If you're not using a server, it seems like dynamically adding entire pages of content might be overkill. – Dryden Long Jan 06 '17 at 14:45
  • Posible duplicated: http://stackoverflow.com/questions/2990518/jquery-load-not-working-in-chrome – Troyer Jan 06 '17 at 14:45

1 Answers1

1

This is due to chrome security policies. If you don't disable it you won't be able to load local file.

You can disable it by running chrome with the following command on windows.

chrome.exe --allow-file-access-from-files

There's a bit more information here.

Community
  • 1
  • 1
Kiogara
  • 617
  • 1
  • 6
  • 15
  • You should include a short summary of the link in case it becomes invalid, also note that the top voted answer is probably better than the accepted one. – Hoi_A Jan 06 '17 at 15:39