Hi i want to display multiple table and the table data will be dynamically brought by consuming json data on single button click using ajax & javascript,jquery . For single table i can generate table using this below procedure.
$.ajax({
type: 'GET',
url: xxx.xxx.xxx.xxx,
data: "Id=" + clO + "&Location=" + clOp +"",
success: function (resp) {
var Location = resp;
var tr;
for (var i = 0; i < Location.length; i++) {
tr = tr + "<td style='height:20px' align='left'>" + Location[i].name + "</td>";
tr = tr + "<td style='height:20px' align='right'>" + Location[i].QTY + "</td>";
tr = tr + "<td style='height:20px' align='right'>" + Location[i].AMT + "</td>";
tr = tr + "</tr>";
};
document.getElementById('p_w').style.display = "block";
document.getElementById('Wise').innerHTML = "<table id='rt1' >" + "<thead ><tr><th style='height:20px'>Name</th>" + "<th style='height:20px'>Qty</th>" + "<th style='height:20px'>Amnt</th>"+ "</tr></thead>"
+ tr +
"<tr><td style='height:20px'></td></tr>" +
"</table>";
document.getElementById('Wise').childNodes[0].nodeValue = null;
},
error: function (e) {
SpinnerPlugin.activityStop();
window.plugins.toast.showLongBottom("Please Enable your Internet
SpinnerPlugin.activityStop();
}
});
But for generating the multiple tables using on single click using ajax how can we generate and i want to generate multiple tables in below format
table, th, td {
border: 1px solid black;
}
<body>
<p> Table 1</p>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
<p> Table 2</p>
<table style="width:100%">
<tr>
<th>Subject</th>
<th>Marks</th>
</tr>
<tr>
<td>Science</td>
<td>70</td>
</tr>
<tr>
<td>Computers</td>
<td>80</td>
</tr>
<tr>
<td>Art</td>
<td>70</td>
</tr>
</table>
<p>Table 3</p>
<table style="width:100%">
<tr>
<th>Laptop</th>
<th>Price</th>
</tr>
<tr>
<td>Dell</td>
<td>$350</td>
</tr>
<tr>
<td>Lenovo</td>
<td>$450</td>
</tr>
<tr>
<td>Asus</td>
<td>$200</td>
</tr>
</table>
</body>