Skip to:
Content
Pages
Categories
Search
Top
Bottom

[WORKAROUND] BP 1.5 AJAX Race Condition !!!

  • I’m desperately trying to get ajax callbacks to work without success. I believe I have the the correct semantics, but since it doesn’t work, I’m not so sure. I have ‘wp_ajax_edit_title’ for the action trigger. The $action in the request is ‘action=edit_title’.

    add_action(‘wp_ajax_edit_title’, ‘bp_ group_wiki_edit_title’);
    I’m not sure if the ajaxurl is correct. I have: http://my_domain.com/wp-load.php

    edit: Spending hours searching through code… Couldn’t someone mention:
    1) BP sets ajaxurl to wp-load.php
    2) BP replaces any URL with ‘wp-load.php’ with the referrer in the header !!!
    3) In function bp_core_add_ajax_hook() is where the mangled uri is converted back to an ajax request.
    4) bp_core_add_ajax_hook() executes on action bp_init.
    5) My plugin inits using action ‘bp_init’. Since my plugin inits after BP, the BP action ‘bp_init’ processes AJAX request before my plugin loads,
    6) A bug has been filed for the race condition.

    WORKAROUND:
    1) If possible move all ajax add_action() calls to the Plugin’s initialization function.
    2) Trigger the initialization function using ‘bp_init’ action @ priority 5

    Hopefully this works for you as well as it did for me :)

  • The topic ‘[WORKAROUND] BP 1.5 AJAX Race Condition !!!’ is closed to new replies.
Skip to toolbar