Hi,
I want to retrieve data from objects like OrderId and bookingNr which dont have array's inside of it.
How can I access those data with Ajax GET and output to my datatable?
ajax: {
url: "https://apicheckintest.",
method: "GET",
timeout: 0,
headers: {
Authorization: "Bearer ",
Cookie:
"",
},
dataSrc: "products",
dataType: "JSON",
},
dom: "frtipB",
buttons: [
{
text: "My button",
action: function (e, dt, node, config) {
var test2 = test.rows({ selected: true }).data().toArray();
$.each(test2, function (index, item) {
table += `<tr><td>${test2[index].id}</td><td>${test2[index].passengerFirstName}</td><td>${test2[index].passengerLastName}</td><td>${test2[index].price}</td><td>${test2[index].currency}</td><td>${test2[index].code}</td><td>${test2[index].flightNumber}</td><td>${test2[index].std}</td><td>${test2[index].departureAirport}</td><td>${test2[index].arrivalAirport}</td></tr>`;
});
console.log(table);
console.log($('.productList').val());
$('.productList').val(table);
// console.log(productNames);
// $('.productList').val(productNames);
// NWF$('#CustomerRecordsTable').html(productNames);
},
},
],
columnDefs: [
{
orderable: false,
targets: 0,
className: "select-checkbox",
visible: true,
},
],
columns: [
{ data: null, defaultContent: "" },
{ data: "id" },
{ data: "passengerFirstName" },
{ data: "passengerLastName" },
{ data: "price" },
{ data: "currency" },
{ data: "code" },
{ data: "flightNumber" },
{ data: "std" },
{ data: "departureAirport" },
{ data: "arrivalAirport" },
],
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide