How to call a PHP class function from an ajax call
animal.php
file
class animal
{
function getName()
{
return \"lion\";
}
Can you please mention which are you using any Framework? You method is correct but I want to mention two things over here. First try your URL from the browser and check if its working correctly. Secondly don't use return, in *success: function(data) * data will contain only the output. so use Echo rather then return