Alert elements form returned JSON
Alert elements form returned JSON
I am using the following to set the json returned to a global variable
$('#dtInvoiceDetails')
.on('xhr.dt', function ( e, settings, json, xhr ) {
selectedPrintData = JSON.stringify(json);
} );
the console shows
selectedPrintData = {"data":[{"DT_RowId":"row_10108","inv_list":{"lineID":"10108","InvID":"3113","quantity":"23","barCode":"5555","stockCode":"8686856","size":"77","colour":"","description":"more jjjjjjj","costPrice":"0.00","sellPrice":"5.00","lineTotalNett":"115.00","lineTotal":"0.00","vatRate":"0.00"}}],"options":[],"files":[]}
I have tried
console.log(selectedPrintData[0]['data']['inv_list']['quantity']);
console.log(selectedPrintData[0][data][inv_list][quantity]);
What is the correct way to get thhe returned data into an array then be able to alert the 'quantity' value.
Cheers
Steve Warby
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I got it working but there must be a simpler way to achieve this.
Cheers
Steve Warby
"What is the correct way to get thhe returned data into an array then be able to alert the 'quantity' value."
the data is alredy in an array (of objects): json.data
or something like this
Thanks....