Can i send an Ajax request to a php class method?
Showing comments 1 to 5 of total 5 on page 1 of 1
milanRank: 142
I know how to send Ajax requests to a file specifically for that purpose. Is it possible to make an Ajax request to a php class method?
synergyRank: 279
Yes, you would simply pass the value captured by one of your $_GET, $_POST or $_REQUEST superglobals to your class method.
If you're talking about directly invoking a PHP class method from jQuery, then no, you can't.
crusaderRank: 42
No, you can't directly asscess object's method, but you can request file, which executes that method.
naveenRank: 112
No, but you can map the call to the method. This is more or less what MVC helps you to do. So the call to www.mysite.com/User/Login can be easily mapped to the function Login of the class User. Take a look at Codeigniter.
vishalraoRank: 199
Not in an easy way, But u can try this one:
Ajax is just a term for making an HTTP request from the browser, using JavaScript, without leaving the page. The only thing you can "call" is a URL. You can write your PHP to do something based on what the URL is though.
< ?php if ($_POST['action'] == "delete") {
delete();
}
?>