Parsing JSON and build TR/TD element on each `tipo` value
I have this JSON:
- [ {"tipo":"Diurno"},{"patente":"XZ7410"},{"nombre":"Marcela Bien"},
- {"revisado":1},{"id_registro":"9"},
- {"tipo":"Diurno"},{"patente":"EW3651"},{"nombre":"Marcela Bien"},
- {"revisado":null},{"id_registro":"11"},
- {"tipo":"Vespertino"},{"patente":"XZ7410"},{"nombre":"Alexis Diaz"},
- {"revisado":1},{"id_registro":"10"} ]
Each `tipo` defines a new row in a `table` for example:
- <tr>
- <td>Diurno</td>
- <td>XZ7410</td>
- <td>....</td>
- </tr>
- <tr>
- <td>Diurno</td>
- <td>EW3651</td>
- <td>....</td>
- </tr>
- <tr>
- <td>Vespertino</td>
- <td>XZ7410</td>
- <td>....</td>
- </tr>
So I wrote this code:
- $(document).ready(function() {
- $.ajax({
- type: 'get',
- url: '<?php echo url_for('dashboard/BuildAjax') ?>',
- dataType: 'json',
- success: function(data) {
- $.each(data, function(k, v) {
- console.log(k + " : " + v);
- });
- },
- error: function() {
- alert('<?php echo __('Error al cargar los datos') ?>');
- }
- });
- });
But I need to create as many TR with TD values as elements come in the JSON values, how I can get this?