Reputation: 12053
I have some code (below) in my html file, I have second file from which I want to load content. Both files are in the same location
<div id="mainMenu"></div>
<script>
$(function() {
$('#mainMenu').load('menu.html');
});
</script>
Everything works great in FireFox, but I have some problem in Chrome: content doesn't appear. Under developer tools in Chrome I see this information about 'Access-Control-Allow-Origin'. There is screen
I don't use sever code, just HTML and jQuery
What should I do to resolve this problem? Any idea?
Upvotes: 0
Views: 407
Reputation: 74420
You should set a local server to serve page because google chrome doesn't allow access by default to local files. However, you could still change chrome setting using option:
--allow-file-access-from-files
See here for more explanation: http://www.chrome-allow-file-access-from-file.com/
Upvotes: 1
Reputation: 7332
Preview your website in a local web-server environent (localhost)
As your console the file path is from your local drive,
Setup a localhost
using any webserver module and test your website using http://
For Eg:
Use
http://localhost/yourwebsite/
instead of
D:/yourwebsite/
You can use wamp or xamp to setup a local environment.
Upvotes: 0
Reputation: 3949
You're trying to execute a file and request on localhost.
Try to run this file on localhost (with wamp or local server), not only executing the html. There should not be any cross-origin problem.
Upvotes: 0