Problem:
I'm using a view with AJAX sorting and filtering, along with the "Show only filter options that would produce results" feature. It works perfectly in Safari but not in Chrome, where it endlessly loads. Disabling AJAX and the filter option resolves the issue in Chrome.
Solution:
The issue is related to a CORS error that occurs when accessing the site without the "www" prefix in the URL. The AJAX request is blocked because it is treated as a cross-origin request. To resolve this, you need to configure your server to include the Access-Control-Allow-Origin header for the admin-ajax.php file. This can be done by modifying your server's configuration:
1. For Apache:
Add the following to your .htaccess file:
<ifmodule mod_headers.c> Header set Access-Control-Allow-Origin "https://mlpt.com" Header set Access-Control-Allow-Methods "GET, POST, OPTIONS" Header set Access-Control-Allow-Headers "Content-Type" </ifmodule>
2. For Nginx:
Add the following to your server block configuration:
location /wp-admin/admin-ajax.php { add_header 'Access-Control-Allow-Origin' 'https://mlpt.com'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'Content-Type'; }
3. In WordPress (PHP):
Alternatively, add this to your theme’s functions.php or a custom plugin:
function add_cors_http_header() { header("Access-Control-Allow-Origin: https://mlpt.com"); header("Access-Control-Allow-Methods: GET, POST, OPTIONS"); header("Access-Control-Allow-Headers: Content-Type"); } add_action('init', 'add_cors_http_header');
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
This topic contains 7 replies, has 2 voices.
Last updated by 3 months, 2 weeks ago.
Assisted by: Christopher Amirian.