I have the following table which I will like to set the rows with some values from an api when the page loads. I have some static values for now and the api returns a JSON array.
<table class="table table-striped table-valign-middle">
<thead>
<tr>
<th>Product</th>
<th>Price</th>
<th>Sales</th>
<th>More</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<img src="default-150x150.png" alt="Product 1" class="img-circle img-size-32 mr-2" />
product 1
</td>
<td>$ 200</td>
<td>
<small class="text-success mr-1">
<i class="fas fa-arrow-up"></i>
0.5%
</small>
2 Sold
</td>
<td>
<a href="#" class="text-muted">
<i class="fas fa-search"></i>
</a>
</td>
</tr>
</tbody>
</table>
I have the following information in the JSON array as an example and product , price, sales maps to Name, price and count respectively. would like to do that via JavaScript or jquery.
+-----------+-------------+-------+------+-------+
| ID | Name | Price | URL | Count |
+-----------+-------------+-------+------+-------+
| 1 | Book | 2 | url1 | 2 |
| 2 | Pen | 1 | url2 | 1 |
| 3 | pencil | 1 | url3 | 1 |
+-----------+-------------+-------+------+-------+