Access to XMLHttpRequest at ‘https://dp.api.yyyy.com/index.php?pattern_name=Adapter ’ from origin ‘http://localhost ’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
where is the problem jQuery or PHP7… CORS policy? trying jQuery ajax request json from localhost calling external server online… in browser give result…well? but for jquery app error
<?php // index.php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: PUT, GET, POST");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
...
echo (json_encode(getPatternData($pattern_name)));
?>
They need to send the appropriate CORS header. No header you’ll send on your side has any effect.
Can you post here the header you refer??? what is missing??? isn’t this
header(“Access-Control-Allow-Origin: *”);
I also tried like this: but the same
header(“Access-Control-Allow-Origin: *”);
header(“Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept”);
header(“Access-Control-Allow-Methods: PUT, GET, POST”);
header(‘Content-Type: application/json’);
The owner of dp.api.yyyy.com
need to set a header on their server.
No amount of headers you set on your server is going to make any difference.
You need to ask them to fix it, you can’t fix it yourself.
You may want to read up on what CORS actually is: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
by this — what you mean? where set the header? PHP headers are not set in php files?
rpkamp
July 8, 2020, 10:36am
6
Contact the webmaster of dp.api.yyyy.com
and tell them your problem. They need to fix it.
You can not fix it.
system
Closed
October 7, 2020, 5:37pm
7
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.