I am using datatables to get data from json but when the page is ready tbody show loading... instead showing data from json response
here is my json
{"response":{"data":[{"id":"64D3AFAFA8DE403A92DD836AC12ED903","organization":"3F8B3208255142DCB1D5C7AE542847B0","createdBy":"534F676339874A288518CD9D19086219","description":null,"documentNo":"PR.64","businessPartner":"DE1D64A7DED34BE3BBD1EA8BBA6540A1","documentStatus":"oez_waitingcomplete","recordTime":1634267761609}],"status":0}}
my script
$(document).ready(function(){
$('#datatable').DataTable({
"ajax": {
"url": "myurl",
"type": "GET",
"dataSrc": "data"
},
"column": [
{'data': 'documentNo'},
{'data': 'organization'},
{'data': 'createdBy'},
{'data': 'documentStatus'},
{'data': 'description'},
{'data': 'id'}
]
})
})
CodePudding user response:
For this to work you must simply change your dataSrc
to "response.data"
.
The data
array is inside the response
object in your json response so this should do the trick.