Why is admin ajax reloading my page

This is probably the new Heartbeat API. It is running in intervals from 15 to 60 seconds and offers a simple way to communicate with WordPress per AJAX in the background. You can disable it in JavaScript with wp.heartbeat.stop(); and in PHP with remove_action( ‘admin_init’, ‘wp_auth_check_load’ ); (might not be enough on some pages).

jQuery UI Autocomplete showing all results

You get all terms because you’re asking for all terms, in fact, the line $tradeList = get_terms(‘trade’); just get all the terms, ignoring the ‘term’ query string passed to file. If you want to get all the terms “filterd” you have to use the string in the query, something like: include_once( ‘../../../wp-load.php’ ); // adjust … Read more

Ajax with OOP doesn’t work

You need to create a new instance of the class so that your constructor is called and your actions are registered. e.g. you need to add something like $test = new PR_Test; below the definition of PR_Test.

edit-comments.php comment_row_actions ajax problem

I resolved this issue by using the wp-ajax environment. Essentially, I created the callback function for the comment_row_actions filter which created the link pointing to admin-ajax.php in the admin directory with a query string. Then I created the add_action to run in the wp_ajax environment with a redirect back to the referring page. I couldn’t … Read more

Ajax function returns -1

Rarst said it worked for him both logged in and logged out, i can also confirm the same, here’s my ugly test code that works, very much just a hacked together version of your code(for testing). function say_coucou(){ check_ajax_referer( ‘hello’, ‘nonce’ ); echo “Hello”; die; } add_action(‘wp_ajax_hello_hello’, ‘say_coucou’); add_action(‘wp_ajax_nopriv_hello_hello’, ‘say_coucou’); add_action(‘admin_print_footer_scripts’,’blabla’,20000); add_action(‘wp_head’,’enj’,20000); add_action(‘wp_footer’,’blabla’,20000); function enj() … Read more

Ajax response is always 0

You can’t add AJAX calls from public templates. They have to get added much earlier The file that passes the call is admin-ajax.php for a reason: Ajax calls must not be hidden outside admin. For e.g. wrapping your call inside ! is_admin() will let it fail. Template files are not meant to hold actual function … Read more