WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Marko-M
    Member
    Posted 1 year ago #

    Hello,
    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,
    Marko

    http://wordpress.org/extend/plugins/wordpress-https/

  2. Caspie
    Member
    Posted 1 year 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:

    <?php
    /**
     * WordPress AJAX Process Execution.
     */
    
    define( 'DOING_AJAX', true );
    
    /** Load WordPress Bootstrap */
    require_once( '../../../wp-load.php' );
    
    /** Allow for cross-domain requests (from the frontend). */
    send_origin_headers();
    
    // 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' );
    
    send_nosniff_header();
    
    add_action( 'wp_ajax_nopriv_autosave', 'wp_ajax_nopriv_autosave', 1 );
    
    if ( is_user_logged_in() )
    	do_action( 'wp_ajax_' . $_REQUEST['action'] ); // Authenticated actions
    else
    	do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] ); // Non-admin actions
    
    // Default status
    die( '0' );

    Hope this helps!

  3. jtudisco
    Member
    Posted 1 year 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. Mvied
    Member
    Plugin Author

    Posted 1 year 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
    Member
    Posted 1 year 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
    Member
    Posted 1 year 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

About this Topic