I have this structure:
HTML part:
<table id="table_div" class="table table-striped table-condensed"><tbody></tbody></table>
JS part:
var data = json_response['data'];
$("#table_div").html('<thead><tr><td>TIMESTAMP</td><td>VALUE</td></tr></thead>');
$.each(data, function(index, value) {
$('#table_div > tbody:last').append('<tr><td>' + value + '<td></tr>');
});
Now, my vector data, taken from the java console, is this for example:
{"data": [[1348754599, 0.0], [1348754639, 0.0], [1348754680, 0.0], [1348754721, 0.0], [1348754761, 0.0], [1348754802, 0.0], [1348754842, 0.0], [1348754883, 0.0], [1348754924, 0.0], [1348754964, 0.0], [1348755005, 0.0], [1348755045, 0.0], [1348755086, 0.0], [1348755126, 0.0], [1348755167, 0.0], [1348755208, 0.0]]}
And at this moment the result is that the timestamp and the value are toghether under TIMESTAMP, but column VALUE is empty.
TIMESTAMP VALUE
1348756790,0
1348756830,0
1348756871,0
1348756911,0
1348756952,0
1348756992,0
1348757033,0
How I can i do to have
Timestamp Value
12876 0
129487 1
Thank you very much!
*EDIT*
This is the html generated now:
<table id="table_div" class="table table-striped table-condensed"><tbody><tr><td>TIMESTAMP</td><td>VALUE</td></tr><tr><td>1348760408,0</td><td></td></tr><tr><td>1348760448,0</td><td></td></tr></tbody></table>
My previous answer was bogus. I misremembered how
$.each()works.Your original code is correct except that you’re not breaking each element part into its timestamp and value components. I think this code will do what you want: