title: AJAX request and PHP class functions
body: <p>How to call a PHP class function from an ajax call</p>
  
  <p><code>animal.php</code> file</p>
  
  <pre><code>class animal
  {     
    function getName()
    {
      return "lion";
    }
  }
  </code></pre>
  
  <p>Then in my <code>ajax.php</code> file I have an ajax request, need to get values from getName function</p>
  
  <p>How to do that <code>getName()</code> function can I do like this?</p>
  
  <pre><code>&lt;script type=text/javascript&gt;
    $.ajax({
      type: "POST",
      data: {
        invoiceno:jobid
      },
      url: "animal/getName",
      beforeSend: function() {
      },
      dataType: "html",
      async: false,
      success: function(data) {
        result=data;
      }
    });    
  &lt;/script&gt;
  </code></pre>