• Resolved binaryduke

    (@binaryduke)


    Around 20% of our booking form users receive the error message/banner “An AJAX error occurred” when using the form. Our form has a redirect to another page which uses the ‘show all user bookings’. The error typically disappears after a few seconds, the booking is created correctly and the redirect occurs. As this is AJAX, user-side and infrequent, it’s hard for us to view the page source/script inspector. What can we do to minimise/avoid this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author yoancutillas

    (@yoancutillas)

    Hello,

    An AJAX error usually happens when a PHP error occurs during the AJAX request. So we should be able to understand what is going wrong thanks to the PHP error logs.

    Can you

    1.
    Replace in wp-config.php
    define(‘WP_DEBUG’, false);
    with:
    define(‘WP_DEBUG’, true);
    define(‘WP_DEBUG_LOG’, true);
    define(‘WP_DEBUG_DISPLAY’, false);

    2.
    Reproduce the error (“An AJAX error occurred.”)

    3.
    Then, can you send me the wp-content/debug.log file (if it has appeared)? You can send it to me at [email protected].

    Thread Starter binaryduke

    (@binaryduke)

    Thanks. This could easily be down to code that we’re calling from hooks then. We’ll check the wp debug logs at those times.

    Thread Starter binaryduke

    (@binaryduke)

    I think I’ve found it.

    [06-Oct-2022 01:36:16 UTC] PHP Notice: Function get_cart was called <strong>incorrectly</strong>. Get cart should not be called before the wp_loaded action. Backtrace: require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, Essential_Addons_Elementor\Classes\Bootstrap->login_or_register_user, Essential_Addons_Elementor\Classes\Bootstrap->log_user_in, wp_signon, do_action('wp_login'), WP_Hook->do_action, WP_Hook->apply_filters, bookacti_change_customer_id_to_user_id, bookacti_wc_get_cart_items_bookings, WC_Cart->get_cart, wc_doing_it_wrong Please see <a href="https://www.ads-software.com/support/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 2.3.) in /www/tradingresearchgroup_729/public/wp-includes/functions.php on line 5831

    The context here is that the booking form redirects to another page after the booking has been made.

    Plugin Author yoancutillas

    (@yoancutillas)

    Probably not, the AJAX error is shown only if the PHP process is interrupted, a PHP Notice doesn’t stop the process, we are looking for a PHP error.

    This notice shows an compatibility issue between “Essential_Addons_Elementor” and Booking Activities. Essential_Addons_Elementor plugin should not try to log in or register a user on “init” hook, it should be on “wp_loaded” hook or after.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘An AJAX error occurred’ is closed to new replies.