AJAX function returning -1

You are passing ‘eu_custom_query’ as the action in your AJAX. It should be ‘custom_query’.

You decide the action name, when you add the action i.e. ‘wp_ajax_my_action’ would be called ‘my_action’

You are confusing it with the callback method. Hope that makes sense.

p.s. to fix your code change:

add_action('wp_ajax_custom_query', 'eu_custom_query');
add_action('wp_ajax_nopriv_custom_query', 'eu_custom_query');

to:

add_action('wp_ajax_eu_custom_query', 'eu_custom_query');
add_action('wp_ajax_nopriv_eu_custom_query', 'eu_custom_query');

Leave a Comment