AJAX request and PHP class functions

后端 未结 8 887
小鲜肉
小鲜肉 2020-12-08 05:29

How to call a PHP class function from an ajax call

animal.php file

class animal
{     
  function getName()
  {
    return \"lion\";
  }         


        
8条回答
  •  渐次进展
    2020-12-08 05:44

    My answer is the same as Surreal Dreams answer, but with the code.

    First. Class animal is OK. Leave it like that:

    animal.php

    Next. Create a new animalHandler.php file.

    getName();
         echo $result;
    }
    

    Finally. Change your Javascript.

    
    

    That's is.

提交回复
热议问题