Topic: How to push a php array reference into a xajax function?

Hello, I'm using a model-view structure in my php module.  When the view is loaded, all of the necessary database operations are done once, and the final array is pushed into the view as $this->data.

Is there a way that I can access this array from a xajax function?

I've tried this:

Code: PHP

$hideDet =& $xajax->register( XAJAX_FUNCTION, 'hideDetails' );

$hideDet->setParameter( 0, XAJAX_JS_VALUE, $this->data );

 

My function looks like this:

Code: PHP

function hideDetails( $theData ){

    $response = new xajaxResponse();

    //more code:  blah blah blah

    foreach( $theData as $c ){

        //do some stuff with $c

    }

    //blah blah

    return $response;

}

 

and at the <body>,  this:

Code: PHP

<a href="javascript:;" onclick="<?php $hideDet->printScript(); ?>">Hide Details</a>

 


When I watch the generated sourcecode, I have this:

Code: PHP

<a href="javascript:;" onclick="xajax_hideDetails(Array)">Hide Details</a>

 

Should I use another indicator instead of XAJAX_JS_VALUE ?

When I alert( $theData ), the content is NULL.

Thanks.

Re: How to push a php array reference into a xajax function?

my intuition would say, this will not work, due to that your are outputting a string with printScript...

you've got 2 alternatives either:
in the php ajax function, make a $objResponse->script() and somehow fill a javascript array. and then access it through the xajax_hideDetails. (i wouldn't do that)

or:
you make a implode() on the array, and then explode it again into a array again in the specific function