By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

How To call a function in php oop class? using ajax?

Exequiel
100+
P: 287
Hello friends, i want to know if how to call a php oop class function like mainCategory using ajax, this is the code for ajax,
Expand|Select|Wrap|Line Numbers
  1.  
  2. var d = "Zick";
  3. $.ajax({
  4.         type: "post",
  5.         url: "e_class.php/mainCategory",
  6.         data:{
  7.             d:d
  8.         },
  9.         success: function(inlog){
  10.             alert(inlog);
  11.         }
  12.     });
  13.  
and this is for the php

Expand|Select|Wrap|Line Numbers
  1. class E_class
  2. {
  3.  
  4.     public function mainCategory()
  5.     {
  6.         echo $_POST['d'];
  7.     }    
  8.  
  9. }
  10.  
  11.  
I made it with codeIgniter but without codeigniter i can't call the funtion, , any reply are appreciated. . :D
Dec 5 '13 #1
Share this Question
Share on Google+
3 Replies


Dormilich
Expert Mod 5K+
P: 8,639
you cannot call a class directly from AJAX, only a whole script. (but you can of course use an URL that indicates you want a certain class to be called).
Dec 5 '13 #2

Exequiel
100+
P: 287
uhm, , hehe, , I still can't get, I did it in codeIgniter , , can you post some sample codes? :) tnakyou very much. . :D
Dec 5 '13 #3

Exequiel
100+
P: 287
I got it now tnx for the advice @Dormilich . . :D
Dec 5 '13 #4

Post your reply

Sign in to post your reply or Sign up for a free account.