I want to print json (response) into an html table. i want the following information in the table.
data.items.tracking_iddata.items.origin_info.trackinfo.z9.z1.datedata.items.origin_info.trackinfo.z9.z1.Detailsdata.items.origin_info.trackinfo.z9.z1.checkpoint_statushere is my code setup.
const settings = {
"async": true,
"crossDomain": true,
"url": "https://order-tracking.p.rapidapi.com/trackings/realtime",
"method": "POST",
"headers": {
"content-type": "application/json",
"x-rapidapi-host": "order-tracking.p.rapidapi.com",
"x-rapidapi-key": "c1b4466148msh84c499d6e5590c4p155c1bjsne8487b7633cc"
},
"processData": false,
"data": {
"tracking_number": "CM436202938IN",
"carrier_code": "india-post"
}
};
setInterval(function() {
$.ajax(settings).done(function (response) {
//console.log(response);
var sdata = '';
$('#trackinfo').empty();
$.each(response, function(key,value){
sdata += '<tr>';
sdata += '<td>'+value.data.items.tracking_number+'</td>';
sdata += '<td>'+value.data.items.origin_info.trackinfo.z9.z1.date+'</td>';
sdata += '<td>'+value.data.items.origin_info.trackinfo.z9.z1.Details+'</td>';
sdata += '<td>'+value.data.items.origin_info.trackinfo.z9.z1.checkpoint_status+'</td>';
sdata += '</tr>';
});
$('#trackinfo').html(sdata);
}); }, 50000);
<table class="">
<thead>
<tr>
<th>Tracking ID</th>
<th>Update Date</th>
<th>Current City</th>
<th>Current Status</th>
</tr>
</thead>
<tbody id="trackinfo">
</tbody>
</table>
I am unable to get tracking information inside the html table. pls improve the code so the tracking information will be reflected inside the html table.