Ajax with plugins returns 0

You can turn your AJAX requests into a REST endpoint to get rid of this common 0 response. All you have to register 2 REST routes for your requests:

add_action( 'rest_api_init', function () {
    //Path to approve comment
    register_rest_route( 'john_doe/v2', '/approve_comment/', array(
            'methods' => 'GET', 
            'callback' => 'approve_my_comment' 
    ) );
    // Path to delete comment
    register_rest_route( 'john_doe/v2', '/remove_comment/', array(
            'methods' => 'GET', 
            'callback' => 'remove_my_comment' 
    ) );
});

And now, in your callback functions:

function approve_my_comment(){
    return 'Approved';
}
function remove_my_comment(){
    return 'removed';
}

Now you will be able to run your functions by visiting example.com/wp-json/john_doe/v2/approve_comment.

That’s all. No more dilly dally and 0 responses.

Remember that REST callback functions must return a value, not echo it.