Suppose you have a PHP variable or an object which you want to pass to a Javascript function whenever a button is clicked. Following this tutorial, you will be able to do so.
Source code:
https://adnan-tech.com/send-php-objec...
We will not be directly sending the PHP variable, but instead we will attach the PHP variable to the HTML tag attribute and then send that tag to the Javascript function.