HTML Table data to JSON string in Javascript
Posted: 18 Nov 2014, 08:45
Hi,
I have this HTML table. How can I get the TD data from each row in JavaScript (in JSON format) to be passed via Ajax to a PHP script?
I have this HTML table. How can I get the TD data from each row in JavaScript (in JSON format) to be passed via Ajax to a PHP script?
Code: Select all
<table id="t_id">
<tbody>
<tr>
<th>col_1</th>
<th>col_2</th>
<th>col_3</th>
<th>col_4</th>
</tr>
<tr>
<td>156</td>
<td>2668</td>
<td>100.95</td>
<td>1.82</td>
</tr>
<tr>
<td>256</td>
<td>618</td>
<td>10.35</td>
<td>1.82</td>
</tr>
<tr>
<td>789</td>
<td>28</td>
<td>105.8</td>
<td>15.89</td>
</tr>
</tbody></table>