i bind json data to html table using Ajax,js. In my project i have 4 table headers(S.no,name,year,download link). first three columns sync and working without error.but,last column i need bootstrap download button with inserted link . how i do this using json?
exact what i need: if i load the page, s.no,name,year,bootstrap download button + inserted link i need.
html
<body>
<div class="container">
<div class="first bg-primary">
<h2>A R Rahman All Movies</h2>
<p>Download songs free</p>
</div>
<!-- -->
<table id="personDataTable" class="table table-dark table-hover">
<thead>
<tr>
<th>S.No</th>
<th>Movie Name</th>
<th>Year</th>
<th>Download Link</th>
</tr>
</thead>
</table>
<!-- table end -->
<script>
$.ajax({
//url: 'https://jsonplaceholder.typicode.com/posts',
url: 'https://10rs.000webhostapp.com/json-data.json',
type: "get",
dataType: "json",
success: function (data) {
drawTable(data);
}
});
function drawTable(data) {
for (var i = 0; i < data.length; i++) {
drawRow(data[i]);
}
}
function drawRow(rowData) {
var row = $("<tr />")
$("#personDataTable").append(row);
row.append($("<td>" + rowData.id + "</td>"));
row.append($("<td>" + rowData.name + "</td>"));
row.append($("<td>" + rowData.year + "</td>"));
row.append($("<td>" + rowData.link + "</td>"));
}
</script>
<footer class="bg-danger">
<p>Design and Developed by Rajadurai</p>
</footer>
</div>
<!-- container end -->
</body>
And this is the output of data
[
{
"id": 1,
"name": "Roja",
"year": "1992",
"link": "<a href="#" class="btn btn-info" role="button">Link Button</a>"
},
{
"id": 2,
"name": "Gentleman",
"year": "1993"
},
{
"id": 3,
"name": "Kizhakku Cheemayile",
"year": "1993"
},
{
"id": 4,
"name": "Pudhiya Mugam",
"year": "1993"
},
{
"id": 5,
"name": "Thiruda Thiruda",
"year": "1993"
}
]