• Hi,
    We get a JS error when searching for a keyword. The ajax results list does not appear. In the dev console we get following error:

    jquery.ajaxsearchlite.min.js?ver=4.7.25:3 Uncaught TypeError: Cannot read property ‘1’ of null

    Surprisingly, the search works as expected when logged-in (as Administrator).

    This seems to us related to an ajax issue – where ajax execution is only allowed by logged-in users. I can’t find any related settings/options for the ajax behaviour in the WordPress Settings section for the plugin.

    Are you able to assist?

    Debug info: https://paste.ee/p/eGPBY#NFVnqgqJhpDk6PVp3pTTfuen3VFHktaV
    WP: 4.9.10
    Plugin version: 4.7.25

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter wordpsam

    (@wordpsam)

    Follow up with further info from our devs:

    Similiar cause: https://wordpress.stackexchange.com/questions/280607/simple-wordpress-ajax-plugin-not-working-when-not-logged-in

    // logged-out users
    add_action( ‘wp_ajax_nopriv_my_action_search_key_press’, ‘action_search_key_press_callback’ );

    // authenticated users
    add_action( ‘wp_ajax_my_action_search_key_press’, ‘action_search_key_press_callback’ );

    Console network debug:
    admin-ajax.php (canceled) type XHR

    Plugin Author wpdreams

    (@wpdreams)

    Hi,

    Thank you very much for all the details!

    The issue is, that the ajax request returns an incorrect response, it basically returns the whole site as the request response. These issues usually happen when:
    – There is either a function declared somewhere, that interrupts the execution, mostly code that checks for $_POST or $_REQUEST variables
    – More likely, there is a malformed mod_rewrite rule within the root .htaccess file
    I would first recommend checking these, it is very likely one of them causing the problem.

    As a bypass, you can try enabling the custom ajax handler feature, which may circumvent this problem, however I still recommend investigating what exactly is interrupting the ajax handlers.

    Best,
    Ernest M.

    Thread Starter wordpsam

    (@wordpsam)

    Hi Ernest,
    thanks for the feedback – I forward to our devs – mod_rewrite / .htaccess is a good tip.

    Let you know how we go.

    Thanks

    Thread Starter wordpsam

    (@wordpsam)

    Hi Ernest,

    after a long testing session we were able to pin down the issue to a plugin which requests member information through an API token. Activating/deactivating that plugin enables/re-enables the issue. So… this is not a bug in relation to your plugin but your search plugin is affected by the behaviour and restrictions of the other one.

    I leave this thread open it might be useful for someone else in future and if we find a feasible solution to avoid this clash I will post it here.

    cheers

    Plugin Author wpdreams

    (@wpdreams)

    Thank you very much for letting me know!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘ajax results not working when logged-out’ is closed to new replies.