Download Google Chrome Latest Version Offline

Posts about google chrome

26 July 2016

Chrome error origin null is not allowed by access control allow origin

Chrome error origin null is not allowed by access control allow origin


Solution of Chrome error origin null is not allowed by access control allow origin

1st Solution:

Origin null is not allowed by Access-Control-Allow-Origin means that you are trying to perform Ajax on a local file. This is forbidden for security reasons. Even if this was not the case, your PHP wouldn't run because PHP is supported by web servers, not web browsers.

You have a web server installed. You have to request your pages through the server, rather than accessing them directly from your file system.

Use a URL starting with http://localhost/

You will need to move your files so that they are under the server's DocumentRoot (or reconfigure the server so that it can access them from their present location).

2nd Solution:


I'm not sure which browser you are testing for. In my case, it works for all my browsers if I sent AJAX calls from local file, which means the Origin is null. I guess the reason you can not get it work is that some server side coding are needed.

Try this, add the Access-Control-Allow-Origin header to the HTTP response and set the value to *. I'm not sure how to do this in PHP, but here's a piece of Java code for your information.

response.setHeader("Access-Control-Allow-Origin", "*")

3rd Solution:


There is this chrome plugin allows to request any site with ajax from any source. Adds to response 'Allow-Control-Allow-Origin: *' header

https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi/related

It worked for me without needing to change anything on the server side. But you should change withCredentials: false in the request, if it conforms with your tests.

Translate

Popular Posts

Contents

Blog Archive

Powered by Blogger.