Accessing json return

Wow. Sorry for the flurry of posts in the past couple days, but they're in lieu of one good full example in any of the docs.

I successfully receive the json return from the ajax call:

CHtml::ajax(array('dataType'=>'json','data'=>array('zip'=>'js:this.value'),'success'=>'function(data,textStatus)
...

Firebug shows the return as {'city':'New York'}{'city':'Atlanta'} (In the php sending page I'm using CJSON::encode)

I can't seem to find a way to access this return as the var 'data' in the success function. I've tried to raise an alert (alert works with a string, so the function is firing), but data[0].city, data, data(0).city, data[0].responseText.city, etc.



CHtml::ajax(array(


    'dataType'=>'json',


    'data'=>array('zip'=>'js:this.value'),


    'success'=>'function(data,textStatus){ alert(data[0]) }',


));


Try above code. I think that data contains array of cities in your example, so e.g. data[0][1] should contain 'New York'.

No alert fires. Here's the interesting thing.

If I remove the 'dataType'=>'json' from the call, the return is identical. A string alert ('hello world') will fire, and alert(data[0][1]) fires as undefined, but alert[data] will fire with {'city':'Atlanta'}{'city':'New York'}. 

If I have the dataType parameter, even though the return looks exactly the same in firebug, the 'error' function fires.

Ah, figured it out. The problem was on the sending side, not the receiving side. I was looping through a recordset, echo'ing an encode() for each row, where I should have just passed the entire recordset to encode.