Problem with JSON
-
$message is an associated mass recovered after request for OBD
On the 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)
Problem is, I have to hand over all messages from the OBD system, through JSON, and get them out through innerHTML, but it only transmits the first messages.
-
This should work:
$res = array(); foreach( $message as $mes ){ $res[] = array( 'name' => $mes['name'], 'content' => $mes['content'] ); } echo json_encode( $res );