AJAX on Front-End Button Click Does not Work – Custom Plugin

I'm trying to create a custom plugin, and what should be simple gives me a huge headache. I have followed exactly the example of WordPress Codex and have looked at countless similar messages, but nothing has worked for me.

Here is the structure of my code:

In the file my_plugin.php, which contains my main plugin class and all my php functions that I have (in my main class):

public service __construct () {
add_action (& # 39; wp_ajax_foobar & # 39;; & # 39; my_ajax_foobar_handler & # 39;);
add_action ('wp_ajax_nopriv_foobar', 'my_ajax_foobar_handler');
}

public service my_ajax_foobar_handler () {
error_log ("Ajax callback");

// do not forget to stop running after.
wp_die ();
}

In another page, my_page.php I have:




When I click on the button, my log file correctly takes the "click on the obtained button", so that the click on the button is detected at the beginning. However, my debug log does not recover the "Ajax callback". I do not understand why it does not work.

Any help would be appreciated. Thank you.