WordPress HTTPS (SSL)
[resolved] WordPress HTTPS breaks AJAX calls to admin-ajax.php (6 posts)

  1. Marko-M
    Posted 3 years ago #

    when HTTPS is activated only on backend all frontend AJAX calls to WordPress preferred AJAX callback handler wp-admin/admin-ajax.php fail due to browsers Same origin policy. This breaks many plugins for a lot of users. What can be done?

    Thanks and regards,


  2. Caspie
    Posted 3 years ago #

    Well, I had similar issue, so I copied admin-ajax.php to my theme directory and removed the unneeded stuff. Then use it for your ajax calls instead of the wp-admin one.

    Reffer to the file:

    <?php get_template_directory_uri(); ?>/admin-ajax.php

    This is my admin-ajax.php according the latest WP 3.4.2:

     * WordPress AJAX Process Execution.
    define( 'DOING_AJAX', true );
    /** Load WordPress Bootstrap */
    require_once( '../../../wp-load.php' );
    /** Allow for cross-domain requests (from the frontend). */
    // Require an action parameter
    if ( empty( $_REQUEST['action'] ) )
    	die( '0' );
    @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
    @header( 'X-Robots-Tag: noindex' );
    add_action( 'wp_ajax_nopriv_autosave', 'wp_ajax_nopriv_autosave', 1 );
    if ( is_user_logged_in() )
    	do_action( 'wp_ajax_' . $_REQUEST['action'] ); // Authenticated actions
    	do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] ); // Non-admin actions
    // Default status
    die( '0' );

    Hope this helps!

  3. jtudisco
    Posted 3 years ago #

    How about other plugins? This is a good solution for your own code. But what if your not working with your own code. There should be a way to add an exception for admin-ajax.php.

  4. Mike Ems
    Plugin Author

    Posted 3 years ago #

    I'll have a fix out in the next release. If you'd like, try the development version and let me know if it works for you.

  5. infobydesign
    Posted 3 years ago #

    I've been pulling my hair out over this Ajax issue for weeks - after installing the Dev version of your plugin, the problem is resolved. Many thanks!

  6. fluesey
    Posted 3 years ago #

    Just to let people know that installing the Dev version (3.4.0b) still fixes this problem, with no settings changed. Great plugin by the way.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress HTTPS (SSL)
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic