$ message is an associative array returned after a query to the database
On server
foreach($message as $mes) { $array = array('name' => $mes['name'], 'content' => $mes['content']); echo json_encode($array); }
On the client
var message = JSON.parse(this.responseText)
The problem is that I need to send all messages from the database, via JSON and output them through innerHTML, but it transmits only the first message