PHP snippets intended for shortcode use aren't going to work here (unless the plugin explicitly offers a solution, in which case ask them).
To properly use AJAX in WordPress you need to put the functions in your child theme's functions.php file or a simple plugin. Then you need to either:
- Hook the function into the
wp_ajax_
hooks and send your request to/wp-admin/admin-ajax.php
. That's documented here. - Or create a custom endpoint for the REST API and send the request to your endpoint. That's documented [here])(https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/).