This is my postman collection which I want to show into my ajax data table.
I want to show few selected data from it.
I am getting this data in my ajax response but not able to show it in my table
My ajax code is this.
"doc":[ {
"billingDate": "2022-04-11T11:54:16.600Z",
"_id": "6256ce0404de4671d565cca6",
"serviceProvider": {
"blocked": false,
"isLoggedIn": true,
"createdDate": "2022-04-03T20:04:52.082Z",
"_id": "624a01981399dc7a14173dda",
"city": "Karachi",
"email": "[email protected]",
"password": "3460c98eec954a700b17bbac9f14b222",
"providerName": "Test Service",
"address": "123 Street",
"serviceProviderId": "TES321326",
"__v": 0
},
"services": [
{
"_id": "6256ce0404de4671d565cca7",
"serviceName": "husnain",
"actualCost": 60,
"discountedCost": 60
},
{
"_id": "6256ce0404de4671d565cca8",
"serviceName": "husnain",
"actualCost": 60,
"discountedCost": 70
},
{
"_id": "6256ce0404de4671d565cca9",
"serviceName": "husnain",
"actualCost": 60,
"discountedCost": 80
}
],
"total": 210,
"company": {
"blocked": false,
"isLoggedIn": false,
"createdDate": "2022-04-03T12:14:51.356Z",
"_id": "62498fc7acd7fb091185b88d",
"email": "[email protected]",
"companyName": "Yozio",
"address": "1 Buhler Road",
"image": "http://dummyimage.com/327x225.png/dddddd/000000",
"companyId": "UDB21WROMBA8",
"password": "3460c98eec954a700b17bbac9f14b222",
"__v": 0
},
"employee": {
"createdDate": "2022-04-03T17:09:47.994Z",
"enabled": true,
"_id": "6249d52bfef2560326a740e7",
"fName": "James Bartley",
"age": 30,
"CNIC": "3974224221510",
"spouse": "Hilary",
"fatherName": "James",
"motherName": "Brunhilde",
"employeeImage": "http://dummyimage.com/267x237.png/ff4444/ffffff",
"employeeID": "YO550717",
"company": "62498fc7acd7fb091185b88d",
"children": [],
"__v": 0
},
"billId": "YOTE529822",
"__v": 0
},
]
I want to show employee name, Employee ID , Services array object. I am getting this data in response but not able to show this in my datatable.
$(document).ready(function() {
$.ajax({
type: "POST",
contentType: "application/json",
url: 'https://2057-185-202-239-227.ngrok.io/serviceprovider/billByServiceProvider',
data: JSON.stringify({
serviceProvider: sessionStorage.getItem("Services_id"),
}),
dataType: "json",
success:function(response){
$('#example12').DataTable({
"ajax": 'response.doc'
});
}
});
});