Welcome Guest, Not a member yet? Register   Sign In
Global variable in a class not working (using Ajax)
#5

[eluser]mvdg27[/eluser]
Well, it's as simple as this: instead of setting a global var in your script ($this->my_var = 'my value'), you have to make sure that every function accepts the var as a parameter:

Code:
function foo($var1, $var2, $var3, $my_var) {

}

So when you are making your ajax calls, be sure to either hard code, or print the value of your var in the javascript handler.

The most important thing to remember is that, each ajax call, loads a complete new instance of the controller. Hence there is no memory in the form of global variable available.

Hope that helps.

Michiel


Messages In This Thread
Global variable in a class not working (using Ajax) - by El Forum - 05-28-2008, 06:58 AM
Global variable in a class not working (using Ajax) - by El Forum - 05-28-2008, 07:22 AM
Global variable in a class not working (using Ajax) - by El Forum - 05-28-2008, 08:17 AM
Global variable in a class not working (using Ajax) - by El Forum - 10-18-2008, 05:44 AM
Global variable in a class not working (using Ajax) - by El Forum - 10-18-2008, 05:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB