Unable to send an associative array in JSON format in Zend to client
Posted
by
Anorflame
on Stack Overflow
See other posts from Stack Overflow
or by Anorflame
Published on 2011-02-16T15:22:38Z
Indexed on
2011/02/16
15:25 UTC
Read the original article
Hit count: 174
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...
© Stack Overflow or respective owner