On the server side, You can create an array containing all the data you need and then send it from the server to the client using json_encode() :
$data = array(
'response' => array(
'error' => 1,
),
'someData' => 'data',
...
);
print json_encode($data);
And on the client side :
var json = JSON.parse(data);
alert(json.response.error);
Hope it helps !