Filter WP user acf field by ajax

The problem is your action names don’t match

In your frontend code:

?action=find_coach';

But in your backend code:

    add_action('wp_ajax_search_coach', 'searchLifeCoach');
     add_action('wp_ajax_nopriv_search_coach', 'searchLifeCoach');

search_coach != find_coach, they have to match.

Note that if this code used the REST API, it would have given a 404 and stated the problem in human readable language, e.g.

{
    "code":"rest_no_route",
    "message":"No route was found matching the URL and request method",
    "data":{"status":404}
}

Leave a Comment