1 (edited by cyberbalby 2013-07-05 4:41:33 PM)

Topic: Is it necessary to register class and methods before use with Xajax?

Hello, i'm beginner with xajax and naturally i have some problems that i need help.

I use for my project PHP 5.4.11, Apache 2.2.17, XAJAX-0.6-beta1.

I would like to know if it's necessary to declare my class and methods in xajax before they use. If "YES", how to do.

This is an example of class

class calcul {

   public function addition (int $a, int $b, int $c) {

      return $a+$b+$c;
   }
   public function substraction(int $a, int $b, int $c) {

      return $a-$b-$c;
   }
   public function multiplication(int $a, int $b, int $c) {

      return $a*$b*$c;
   }

}

$d = addition(5,10,30)+substraction(50,25,2)+multiplication(32,150,5);
echo $d;

Excuse me i'm a french speaker, idon't speak correctly English

Re: Is it necessary to register class and methods before use with Xajax?

As far as I know you should declare your php functions
$xajax->registerFunction(namefunction)

Re: Is it necessary to register class and methods before use with Xajax?

Is all i have to do to use my class and his functions?

give me an example please ?

Re: Is it necessary to register class and methods before use with Xajax?

Hello,

Instance your class (i.e $x = new $y();)

Then use $xajax->register(XAJAX_CALLABLE_OBJECT, &$y);

This will register all functions in the class.

In your html you have to use the original class name:  onclick=xajax_X_function(...)

Hope this helps.

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.