XMLHttpRequest
cannot load http://example.com/test.php.
No Access-Control-Allow-Origin
header is present on the requested resource. Origin http://eample.com
is therefore not allowed access.
How to resolve it. i added following headers in that php file:
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Origin, Content-Type, Accept,
Authorization, X-Request-With');
header('Access-Control-Allow-Credentials: true');
i replace my domain name 'codeXXX' with 'example' dont confuse with that
The header
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
MUST be given in response to an OPTION request to "http://example.com/test.php". If OPTION request contains this header, the following GET (or POST) will be accepted.
If the browser says that the header "Access-Control-Allow-Origin" is not present, ... just add it ^_^
header('Access-Control-Allow-Headers: Access-Control-Allow-Origin, Origin, Content-Type, Accept, Authorization, X-Request-With');