How to call a PHP class function from an ajax call
animal.php file
animal.php
class animal { function getName() { return \"lion\"; }
My answer is the same as Surreal Dreams answer, but with the code.
First. Class animal is OK. Leave it like that:
Next. Create a new animalHandler.php file.
animalHandler.php
getName(); echo $result; }
Finally. Change your Javascript.
That's is.