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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Exequiel
    Contributor
    • Jul 2012
    • 288

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

    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,
    Code:
    var d = "Zick";
    $.ajax({
    		type: "post",
    		url: "e_class.php/mainCategory",
    		data:{
    			d:d
    		},
    		success: function(inlog){
    			alert(inlog);
    		}
    	});
    and this is for the php

    Code:
    class E_class
    {
    
    	public function mainCategory()
    	{
    		echo $_POST['d'];
    	}	
    
    }
    I made it with codeIgniter but without codeigniter i can't call the funtion, , any reply are appreciated. . :D
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    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).

    Comment

    • Exequiel
      Contributor
      • Jul 2012
      • 288

      #3
      uhm, , hehe, , I still can't get, I did it in codeIgniter , , can you post some sample codes? :) tnakyou very much. . :D

      Comment

      • Exequiel
        Contributor
        • Jul 2012
        • 288

        #4
        I got it now tnx for the advice @Dormilich . . :D

        Comment

        Working...