admin管理员组文章数量:1201170
I cannot load admin-ajax.php
and I keep getting this error message:
XMLHttpRequest cannot load ..../wp-admin/admin-ajax.php.,. No 'Access-Control-Allow-Origin' header is present on...
On local WAMP it worked just to add this:
header("Access-Control-Allow-Origin: *");
(Even if this seems very stupid because next time WordPress updates I guess this would disappear.)
When I upload this to my production server it's still the same message:
XMLHttpRequest cannot load ..../wp-admin/admin-ajax.php.,. No 'Access-Control-Allow-Origin' header is present on...
I've tried to modify the .htaccess
file and that seemed to activate CORS, but that won't affect admin-ajax.php
:
<IfModule mod_headers.c>
Header add Access-Control-Allow-Origin: *
</IfModule>
I've also tried to install WP-CORS plugin without success.
I cannot load admin-ajax.php
and I keep getting this error message:
XMLHttpRequest cannot load ..../wp-admin/admin-ajax.php.,. No 'Access-Control-Allow-Origin' header is present on...
On local WAMP it worked just to add this:
header("Access-Control-Allow-Origin: *");
(Even if this seems very stupid because next time WordPress updates I guess this would disappear.)
When I upload this to my production server it's still the same message:
XMLHttpRequest cannot load ..../wp-admin/admin-ajax.php.,. No 'Access-Control-Allow-Origin' header is present on...
I've tried to modify the .htaccess
file and that seemed to activate CORS, but that won't affect admin-ajax.php
:
<IfModule mod_headers.c>
Header add Access-Control-Allow-Origin: *
</IfModule>
I've also tried to install WP-CORS plugin without success.
Share Improve this question edited May 29, 2017 at 12:37 Sven 3,6741 gold badge35 silver badges48 bronze badges asked Jan 19, 2016 at 23:27 bestprogrammerintheworldbestprogrammerintheworld 1,3212 gold badges19 silver badges40 bronze badges2 Answers
Reset to default 10There are filters for allowed_http_origins
and add_allowed_origins
.
You can use them to set the proper Access-Control-Allow-Origin header in the response to your AJAX call.
Add this to your theme's functions.php
file:
add_filter('allowed_http_origins', 'add_allowed_origins');
function add_allowed_origins($origins) {
$origins[] = 'https://www.yourdomain.com';
return $origins;
}
Add this to your .htaccess
file:
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
本文标签: headersCannot load adminajaxphp No accesscontrol allow origin*
版权声明:本文标题:headers - Cannot load admin-ajax.php. No access-control allow origin* 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738585434a2101402.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论