<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[xajax Forums - How to push a php array reference into a xajax function?]]></title>
	<link rel="self" href="http://community.xajaxproject.org/feed/atom/topic/8248/"/>
	<updated>2010-04-08T09:18:05Z</updated>
	<generator>PunBB</generator>
	<id>http://community.xajaxproject.org/topic/8248/how-to-push-a-php-array-reference-into-a-xajax-function/</id>
		<entry>
			<title type="html"><![CDATA[Re: How to push a php array reference into a xajax function?]]></title>
			<link rel="alternate" href="http://community.xajaxproject.org/post/29343/#p29343"/>
			<content type="html"><![CDATA[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]]></content>
			<author>
				<name><![CDATA[graemlourens]]></name>
				<uri>http://community.xajaxproject.org/user/4388/</uri>
			</author>
			<updated>2010-04-08T09:18:05Z</updated>
			<id>http://community.xajaxproject.org/post/29343/#p29343</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[How to push a php array reference into a xajax function?]]></title>
			<link rel="alternate" href="http://community.xajaxproject.org/post/28928/#p28928"/>
			<content type="html"><![CDATA[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]
$hideDet =& $xajax->register( XAJAX_FUNCTION, 'hideDetails' );
$hideDet->setParameter( 0, XAJAX_JS_VALUE, $this->data );
[/code]

My function looks like this:

[code]
function hideDetails( $theData ){
    $response = new xajaxResponse();
    //more code:  blah blah blah
    foreach( $theData as $c ){
        //do some stuff with $c
    }
    //blah blah
    return $response;
}
[/code]

and at the <body>,  this:

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


When I watch the generated sourcecode, I have this:

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

Should I use another indicator instead of XAJAX_JS_VALUE ?

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

Thanks.]]></content>
			<author>
				<name><![CDATA[marvingarciac]]></name>
				<uri>http://community.xajaxproject.org/user/3792/</uri>
			</author>
			<updated>2009-12-01T17:56:52Z</updated>
			<id>http://community.xajaxproject.org/post/28928/#p28928</id>
		</entry>
</feed>
