Title: XMLHttpRequest cannot load wp-admin/admin-ajax.php
Last modified: August 23, 2017

---

# XMLHttpRequest cannot load wp-admin/admin-ajax.php

 *  Resolved [Andyt8](https://wordpress.org/support/users/andyt8/)
 * (@andyt8)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/xmlhttprequest-cannot-load-wp-adminadmin-ajax-php-3/)
 * I use SlimStat Analytics at [https://blackseals.net](https://blackseals.net) 
   with WP 4.8.1 and use for several external pages the tracking code. I adjusted‘
   Access-Control-Allow-Origin’ with the “Allow Domains” field. It was working for
   some time.
 * Today I take a look to statistics and missed some requests from myself. So I 
   started searching why…
 * At the moment I get an error message in the webbrowser:
    >>> XMLHttpRequest cannot
   load …/wp-admin/admin-ajax.php. Request header field X-Requested-With is not 
   allowed by Access-Control-Allow-Headers in preflight response. <<<
 * For example one external page: [https://blog.blackseals.net](https://blog.blackseals.net)
 * Is there a bug in SlimStat or a mistake by me in the configuration. Please for
   help.
 * best regards,
    Andyt
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fxmlhttprequest-cannot-load-wp-adminadmin-ajax-php-3%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Saša](https://wordpress.org/support/users/stodorovic/)
 * (@stodorovic)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/xmlhttprequest-cannot-load-wp-adminadmin-ajax-php-3/#post-9433949)
 * Hi [@andyt8](https://wordpress.org/support/users/andyt8/)
 * I’ve tried to fix some similar issues. It seems as trouble with ORIGIN request(
   related to WP core). Possible solution could be:
 * – Add all external domains ( [https://blog.blackseals.net](https://blog.blackseals.net),…)
   using filter [allowed_http_origins](https://developer.wordpress.org/reference/hooks/allowed_http_origins/).
 * – Send header `Access-Control-Allow-Headers:` for ORIGIN request.
 * Possible workaround (for CORS) is (it isn’t perfect):
 *     ```
       add_filter( 'allowed_http_origin', 'xxxxxx_send_cors_headers' );
   
       function xxxxxx_send_cors_headers( $origin ) {
   
               // Access-Control headers are received during OPTIONS requests
               if (  $origin && 'OPTIONS' === $_SERVER['REQUEST_METHOD'] ) {
   
                       if ( isset( $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'] ) ) {
                               @header( 'Access-Control-Allow-Headers: '. $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'] );
                       }
   
               }
   
               return $origin;
   
       }
       ```
   
 * I hope that helps.
 * Regards,
    Sasa
 * PS. Please send your current code related to allow domains if it’s possible.
    -  This reply was modified 8 years, 9 months ago by [Saša](https://wordpress.org/support/users/stodorovic/).
    -  This reply was modified 8 years, 9 months ago by [Saša](https://wordpress.org/support/users/stodorovic/).
    -  This reply was modified 8 years, 9 months ago by [Saša](https://wordpress.org/support/users/stodorovic/).
    -  This reply was modified 8 years, 9 months ago by [Saša](https://wordpress.org/support/users/stodorovic/).
    -  This reply was modified 8 years, 9 months ago by [Saša](https://wordpress.org/support/users/stodorovic/).
 *  Thread Starter [Andyt8](https://wordpress.org/support/users/andyt8/)
 * (@andyt8)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/xmlhttprequest-cannot-load-wp-adminadmin-ajax-php-3/#post-9434202)
 * Thank you for your answer. All external domains were already added through SlimStat
   settings.
 * The only change was adding your “add_filter-Script” and it worked instantly.
 * Thank you very much.
 * regards,
    Andyt
 *  Plugin Contributor [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * (@coolmann)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/xmlhttprequest-cannot-load-wp-adminadmin-ajax-php-3/#post-9434616)
 * Great, thank you both.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘XMLHttpRequest cannot load wp-admin/admin-ajax.php’ is closed to new 
replies.

 * ![](https://ps.w.org/wp-slimstat/assets/icon.svg?rev=2832242)
 * [SlimStat Analytics](https://wordpress.org/plugins/wp-slimstat/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-slimstat/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-slimstat/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-slimstat/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-slimstat/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-slimstat/reviews/)

## Tags

 * [Slimstat Analytics](https://wordpress.org/support/topic-tag/slimstat-analytics/)
 * [XMLHttpRequest](https://wordpress.org/support/topic-tag/xmlhttprequest/)

 * 3 replies
 * 3 participants
 * Last reply from: [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/xmlhttprequest-cannot-load-wp-adminadmin-ajax-php-3/#post-9434616)
 * Status: resolved