This reflect CnsEntries Array in Table format .
JSON Data
{
"statuscode": "200",
"message": "success",
"data": [
[
{
"Id": 1292,
"BillNo": "1292/TATA",
"Lrdate": "/Date(1607279400000)/",
"CustBranch": "BLR",
"CustName": "TATA WAREHOUSE DIVISON",
"FileName": "192.168.1.56/Images/Scan00192.pdf"
"Total": 270000.00,
"CnsEntries": [
{
"BranchCode": "BLR",
"CnsNo": "21235",
"BranchName": "BANGALORE",
"CnsDate": "/Date(1607279400000)/",
"Frieght": 90000.00,
},
{
"BranchCode": "DEL",
"CnsNo": "96425",
"BranchName": "DELHI",
"CnsDate": "/Date(1607339460000)/",
"Frieght": 90000.00,
},
{
"BranchCode": "AHM",
"CnsNo": "43895",
"BranchName": "AHEMDABAD",
"CnsDate": "/Date(1607620080000)/",
"Frieght": 90000.00,
}
],
"TotalCns": 3,
"CustAddress": "\"CW 39, NEAR BHARAT PETROL PUMP, \r\nSANJAY GANDHI TRANSPORT NAGAR,\r\nDELHI - 110042\r\n\r\n",
}
]
],
"count": 1
}
Javascript
function callAPI() {
if (document.getElementById('blno').value != '') {
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "http://192.168.1.56/api/BilInquiry.ashx?apiname=Billinquiry&code=&billno=" + document.getElementById('blno').value, true);
xhttp.onreadystatechange = function ()
{
if (this.readyState == 4 && this.status == 200)
{
var data = this.responseText;
var obj = JSON.parse(data);
var objdata = JSON.stringify(obj.data);
objdata = objdata.substr(1);
objdata = objdata.substring(0, objdata.length - 1);
var parsdata = JSON.parse(objdata);
$('#divResult').empty();
var table = '';
for (var i = 0; i < parsdata.length; i++)
{
var link = '';
var url = '';
if (parsdata[i].FileName != '')
{
var str = parsdata[i].FileName;
var n = parsdata[i].FileName.lastIndexOf('.');
var result = str.substring(n + 1);
if (result.toLowerCase() == 'pdf' || result.toLowerCase() == 'jpeg' || result.toLowerCase() == 'jpg' || result.toLowerCase() == 'png')
{
url = "http://192.168.1.56/Upload/BillFile/" + parsdata[i].FileName;
link = "<a class='btn btn-sm btn-success' href=" + url + " target='_blank'>Download</a>";
}
else
{
link = "";
}
}
else
{
link = "";
}
table += '<table style="border-collapse: collapse" width="100%" cellpadding="0" bordercolor="#E6E6E6" border="1"><tbody>'
table += '<tr><td style="padding:5px;" width="150px"><b>Bill Branch and Bill No.</b></td><td style="padding:5px;">' + parsdata[i].CustBranch + ' - ' + parsdata[i].BillNo + '</td></tr>';
table += '</tbody></table></br>';
}
}
else
{
$('#divResult').empty();
var table = '';
table += '<table style="border-collapse: collapse" width="100%" cellpadding="0" bordercolor="#E6E6E6" border="1"><tbody>'
table += '<tr><td style="padding:5px;" width="150px"><b>Status</b></td><td style="padding:5px;">' + this.responseText + '</td></tr>';
table += '</tbody></table></br>';
}
$('#divResult').html(table);
};
xhttp.send();
}
}