Using PHP-Data (Objects) in JavaScript/JQuery
<p>I have a php-function to fetch events as objects and I want to add them to my existing ul-list via JQuery. I want to transfer the php-variable to JQuery and want to iterate this variable to build up the HTML. I tried it with this one:</p>

<pre><code>$pastEvents = event::getPastEvents($team);
var test = { pastEvents : '&lt;?php echo $pastEvents; ?&gt;' };
for (obj in test.pastEvents) {          
    console.log(obj);
}
</code></pre>

<p>The result i get is only 0, 1, 2, 3, 4, 5,... in the console. The var_dump from PHP looks like this:</p>

<pre><code>array(8) { [0]=&gt; object(game)#10 (17) { ["creatorid":protected]=&gt; int(1) ["tid":protected]=&gt; int(1) ["eid":protected]=&gt; int(12) ["art":protected]=&gt; int(1) ["spielart":protected]=&gt; int(1) ["zeitpunkt":protected]=&gt; string(19) "2012-02-28 11:20:00" ["zeit":protected]=&gt; string(19) "2012-02-18 11:21:50" 
</code></pre>

<p>How can i access the objects from PHP? How can i iterate the variable correctly, that i can access the data like obj.creatorid ... ? </p>

<p>Thanks!</p>

<p>P.S: I could solve this by using jquery's ajax-function - but before the user clicks i already have the data available - so the ajax-request is needless.</p>
