Can i send an Ajax request to a php class method?

Posted in Help the coder! on Jul 9, 2009 at 23:19 IST (about 1 year ago). Subscribe to this post Bookmark and Share Email
Showing comments 1 to 5 of total 5 on page 1 of 1
Post reply
« Previous1Next »

milan
Rank: 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?

Posted by milan on Thursday, July 9, 2009, 11:19 pm
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

synergy
Rank: 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.

Posted by synergy on Friday, July 10, 2009, 7:39 am
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

crusader
Rank: 42

No, you can't directly asscess object's method, but you can request file, which executes that method.

Posted by crusader on Friday, July 10, 2009, 9:42 am
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

naveen
Rank: 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.

Posted by naveen on Friday, July 10, 2009, 10:29 am
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

vishalrao
Rank: 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();
}
?>

 

Posted by vishalrao on Friday, July 10, 2009, 12:31 pm
  • Currently 0.00/5

0 votes

Thank this userFlag this comment
Pages: « Previous1Next »

Post your comment (No registration required)

  Add my comment  

TechieDesi Community

Not signed in (Sign-in or Register)
Be a true TechieDesi!
Top 10 Users
Spread the word
Invite your friends
Fan stuff
Help us improve
Need Help
FAQ's
Search tips
Found a bug? Report!
Feeds and letters
Subscribe via RSS
Archives
Subscribe to newsletter
Unsubscribe e-mail
Miscellaneous
Privacy policy
Visit rootnerve
About us
About us
Support the development
Official Blog
Advertise with us
Careers
Copyright (c) 2008, TechieDesi.com. All rights reserved | About us | Do-Not-Disturb registry | Powered by rootnerve | Page rendered in 0.126 seconds