I have write a code and getting the values via jQuery and Ajax using the following code, the data comes fine but i could not populate the rows in my table. the looping is not work.
This is my table code in html
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Hospital Details</th>
<th>Requested Product</th>
<th>Units</th>
<th>Patient Details</th>
<th>Interval</th>
<th>Requester</th>
</tr>
</thead>
<tbody id="result">
</tbody>
</table>
</div>
<script>
$.get("./../incomingRequestList.php", function(data, status){
var obj = jQuery.parseJSON(data);
for($i=0; $i<obj.length; $i++){
$response += "<tr><td>1</td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
}
$('#result').html($response);
});
</script>
How can i overcome this issue. I am unable to find out why its wrong.
The correct way to do it is:
<script>
$.get("./../incomingRequestList.php", function(data, status){
var obj = jQuery.parseJSON(data);
var response = '';
for(i=0; i<obj.length; i++){
response += "<tr><td>"+obj.number+"</td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
}
$('#result').html(response);
});
</script>