Unable to send an associative array in JSON format in Zend to client
- by Anorflame
Hi,
In one of my actions in a controller, I'm using the json view helper to send back a response to an ajax request. On the client side I alert the data that is passed to the success callback function. It works fine as long as the response is a number or an array with default keys. Once I try to send an associative array, it alerts with [object Object].
Server code:
$childArray = array('key'=>'value');
$this->_helper->json($childArray);
javascript:
function displayChildren(data){
alert(data);
}
...
$.ajax({
url: "/po/add", dataType: "json",
data: {format: "json"}, success: displayChildren
});
I have no idea what am I doing wrong here, so any help would be appreciated...