Does anyone know how I can directly access a function from a PHP class through AJAX (using jQuery).
PHP:
class Blah
{
function __construct()
{
}
function doSomething(data)
{
echo "I am not an animal";
}
}
jQuery:
$.ajax({
url: myClass.php,
data: Blah.doSomething(); "or" Blah->doSomething() "or whatever"
});
I know this is a crude example, i'm just trying to illustrate a point, I hope you can get the gist of my question.
At the moment i'm doing something along these lines:
$.ajax({
url: myClass.php,
data: data : { 'type':'doSomething' }
});
||
if(POST['data']['type'] == 'doSomething')
{
$this->doSomething();
}
And I don't like it...