Cannot load admin-ajax.php. No access-control allow origin*

There 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;
}

Leave a Comment