CORS blocks jquery on Chrome
So I got to do a website for my mediaproduction course.
The task is to enfold a section by clicking on a button. But everytime I click on the button I get some CORS errors in the browser console. The strange thing is, it only happens in Chrome. Firefox works fine.chrome console error
javascript html
add a comment |
So I got to do a website for my mediaproduction course.
The task is to enfold a section by clicking on a button. But everytime I click on the button I get some CORS errors in the browser console. The strange thing is, it only happens in Chrome. Firefox works fine.chrome console error
javascript html
You need to be running your page on a local server not fromfile://protocol in order to use ajax. There are browser extension workarounds but setting up local server is very easy
– charlietfl
Nov 22 '18 at 21:05
Are you on a Mac?
– Randy Casburn
Nov 22 '18 at 21:08
Is the button doing request on local resources or external? As it works in some browsers, I would guess charlietfl solved the mystery already. In that case, I would suggest running a local lightweight server (e.g.: livereload.com) to really avoid any specific behavior while serving local files. If there are external requests, look at developer.mozilla.org/en-US/docs/Web/HTTP/CORS to understand the issue better.
– GriffoGoes
Nov 22 '18 at 21:36
add a comment |
So I got to do a website for my mediaproduction course.
The task is to enfold a section by clicking on a button. But everytime I click on the button I get some CORS errors in the browser console. The strange thing is, it only happens in Chrome. Firefox works fine.chrome console error
javascript html
So I got to do a website for my mediaproduction course.
The task is to enfold a section by clicking on a button. But everytime I click on the button I get some CORS errors in the browser console. The strange thing is, it only happens in Chrome. Firefox works fine.chrome console error
javascript html
javascript html
asked Nov 22 '18 at 20:59
C0baC0ba
13
13
You need to be running your page on a local server not fromfile://protocol in order to use ajax. There are browser extension workarounds but setting up local server is very easy
– charlietfl
Nov 22 '18 at 21:05
Are you on a Mac?
– Randy Casburn
Nov 22 '18 at 21:08
Is the button doing request on local resources or external? As it works in some browsers, I would guess charlietfl solved the mystery already. In that case, I would suggest running a local lightweight server (e.g.: livereload.com) to really avoid any specific behavior while serving local files. If there are external requests, look at developer.mozilla.org/en-US/docs/Web/HTTP/CORS to understand the issue better.
– GriffoGoes
Nov 22 '18 at 21:36
add a comment |
You need to be running your page on a local server not fromfile://protocol in order to use ajax. There are browser extension workarounds but setting up local server is very easy
– charlietfl
Nov 22 '18 at 21:05
Are you on a Mac?
– Randy Casburn
Nov 22 '18 at 21:08
Is the button doing request on local resources or external? As it works in some browsers, I would guess charlietfl solved the mystery already. In that case, I would suggest running a local lightweight server (e.g.: livereload.com) to really avoid any specific behavior while serving local files. If there are external requests, look at developer.mozilla.org/en-US/docs/Web/HTTP/CORS to understand the issue better.
– GriffoGoes
Nov 22 '18 at 21:36
You need to be running your page on a local server not from
file:// protocol in order to use ajax. There are browser extension workarounds but setting up local server is very easy– charlietfl
Nov 22 '18 at 21:05
You need to be running your page on a local server not from
file:// protocol in order to use ajax. There are browser extension workarounds but setting up local server is very easy– charlietfl
Nov 22 '18 at 21:05
Are you on a Mac?
– Randy Casburn
Nov 22 '18 at 21:08
Are you on a Mac?
– Randy Casburn
Nov 22 '18 at 21:08
Is the button doing request on local resources or external? As it works in some browsers, I would guess charlietfl solved the mystery already. In that case, I would suggest running a local lightweight server (e.g.: livereload.com) to really avoid any specific behavior while serving local files. If there are external requests, look at developer.mozilla.org/en-US/docs/Web/HTTP/CORS to understand the issue better.
– GriffoGoes
Nov 22 '18 at 21:36
Is the button doing request on local resources or external? As it works in some browsers, I would guess charlietfl solved the mystery already. In that case, I would suggest running a local lightweight server (e.g.: livereload.com) to really avoid any specific behavior while serving local files. If there are external requests, look at developer.mozilla.org/en-US/docs/Web/HTTP/CORS to understand the issue better.
– GriffoGoes
Nov 22 '18 at 21:36
add a comment |
1 Answer
1
active
oldest
votes
You can use like below quote for MacOS and Windows:
Chrome has a wonderful command line argument to disable web security. To start Chrome with web security disabled, run the following command:
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome --disable-web-security
If you’re using Windows, navigate to the path of your installation via a command prompt and run the following:
Chrome.exe --disable-web-security
reference: https://www.thepolyglotdeveloper.com/2014/08/bypass-cors-errors-testing-apis-locally/
1
hasnt fixed the errors
– C0ba
Nov 23 '18 at 2:30
Try to host file which has ajax in apache server on your machine so it can be opened with localhost/path to your html file inside htdocs or apache public folder which contains your file... I think it will solve your problem with chrome... Chrome 70 and above is too restricted even if we try to make a site with https on localhost
– Poode
Nov 23 '18 at 3:50
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437916%2fcors-blocks-jquery-on-chrome%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use like below quote for MacOS and Windows:
Chrome has a wonderful command line argument to disable web security. To start Chrome with web security disabled, run the following command:
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome --disable-web-security
If you’re using Windows, navigate to the path of your installation via a command prompt and run the following:
Chrome.exe --disable-web-security
reference: https://www.thepolyglotdeveloper.com/2014/08/bypass-cors-errors-testing-apis-locally/
1
hasnt fixed the errors
– C0ba
Nov 23 '18 at 2:30
Try to host file which has ajax in apache server on your machine so it can be opened with localhost/path to your html file inside htdocs or apache public folder which contains your file... I think it will solve your problem with chrome... Chrome 70 and above is too restricted even if we try to make a site with https on localhost
– Poode
Nov 23 '18 at 3:50
add a comment |
You can use like below quote for MacOS and Windows:
Chrome has a wonderful command line argument to disable web security. To start Chrome with web security disabled, run the following command:
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome --disable-web-security
If you’re using Windows, navigate to the path of your installation via a command prompt and run the following:
Chrome.exe --disable-web-security
reference: https://www.thepolyglotdeveloper.com/2014/08/bypass-cors-errors-testing-apis-locally/
1
hasnt fixed the errors
– C0ba
Nov 23 '18 at 2:30
Try to host file which has ajax in apache server on your machine so it can be opened with localhost/path to your html file inside htdocs or apache public folder which contains your file... I think it will solve your problem with chrome... Chrome 70 and above is too restricted even if we try to make a site with https on localhost
– Poode
Nov 23 '18 at 3:50
add a comment |
You can use like below quote for MacOS and Windows:
Chrome has a wonderful command line argument to disable web security. To start Chrome with web security disabled, run the following command:
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome --disable-web-security
If you’re using Windows, navigate to the path of your installation via a command prompt and run the following:
Chrome.exe --disable-web-security
reference: https://www.thepolyglotdeveloper.com/2014/08/bypass-cors-errors-testing-apis-locally/
You can use like below quote for MacOS and Windows:
Chrome has a wonderful command line argument to disable web security. To start Chrome with web security disabled, run the following command:
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome --disable-web-security
If you’re using Windows, navigate to the path of your installation via a command prompt and run the following:
Chrome.exe --disable-web-security
reference: https://www.thepolyglotdeveloper.com/2014/08/bypass-cors-errors-testing-apis-locally/
answered Nov 22 '18 at 21:59
PoodePoode
37337
37337
1
hasnt fixed the errors
– C0ba
Nov 23 '18 at 2:30
Try to host file which has ajax in apache server on your machine so it can be opened with localhost/path to your html file inside htdocs or apache public folder which contains your file... I think it will solve your problem with chrome... Chrome 70 and above is too restricted even if we try to make a site with https on localhost
– Poode
Nov 23 '18 at 3:50
add a comment |
1
hasnt fixed the errors
– C0ba
Nov 23 '18 at 2:30
Try to host file which has ajax in apache server on your machine so it can be opened with localhost/path to your html file inside htdocs or apache public folder which contains your file... I think it will solve your problem with chrome... Chrome 70 and above is too restricted even if we try to make a site with https on localhost
– Poode
Nov 23 '18 at 3:50
1
1
hasnt fixed the errors
– C0ba
Nov 23 '18 at 2:30
hasnt fixed the errors
– C0ba
Nov 23 '18 at 2:30
Try to host file which has ajax in apache server on your machine so it can be opened with localhost/path to your html file inside htdocs or apache public folder which contains your file... I think it will solve your problem with chrome... Chrome 70 and above is too restricted even if we try to make a site with https on localhost
– Poode
Nov 23 '18 at 3:50
Try to host file which has ajax in apache server on your machine so it can be opened with localhost/path to your html file inside htdocs or apache public folder which contains your file... I think it will solve your problem with chrome... Chrome 70 and above is too restricted even if we try to make a site with https on localhost
– Poode
Nov 23 '18 at 3:50
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437916%2fcors-blocks-jquery-on-chrome%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You need to be running your page on a local server not from
file://protocol in order to use ajax. There are browser extension workarounds but setting up local server is very easy– charlietfl
Nov 22 '18 at 21:05
Are you on a Mac?
– Randy Casburn
Nov 22 '18 at 21:08
Is the button doing request on local resources or external? As it works in some browsers, I would guess charlietfl solved the mystery already. In that case, I would suggest running a local lightweight server (e.g.: livereload.com) to really avoid any specific behavior while serving local files. If there are external requests, look at developer.mozilla.org/en-US/docs/Web/HTTP/CORS to understand the issue better.
– GriffoGoes
Nov 22 '18 at 21:36