I'm using a parser in Classic asp to produce the JSON, which looks like this:
{"data":[{"idproduct":1,"description":"Lightweight Flannel","sku":"LGHTFLAN"},{"idproduct":2,"description":"The Unbutton-Down Shirt","sku":"ParentSKU-UNBTNDOWN"},{"idproduct":3,"description":"Daily Grind","sku":"DLYGRND"},{"idproduct":4,"description":"Daily Grind (Silver - navy - Small)","sku":"DLYGRNDnavy"},{"idproduct":5,"description":"Daily Grind (Silver - White - Small)","sku":"DLYGRNDwhite"},{"idproduct":6,"description":"Crown Prints 2","sku":"CRWNPRNTS"},{"idproduct":7,"description":"Duplicate SKU","sku":"Test123"},{"idproduct":8,"description":"$20 Gift Certificate","sku":"GC20"},{"idproduct":9,"description":"Plaid Tie","sku":"tie1"},{"idproduct":10,"description":"Sunset 1","sku":"sun1"}]}
I'm getting this error in the console:
tabulator.min.js:2 Data Loading Error - Unable to process data due to invalid data type
Expecting: array
Received: object
Data: {data: Array(10)}
Can I tell it to look for an object instead?
Hey,
that is because it is returning the data array held in the data property of an object, if you have to send data in this format, then you can use the ajaxResponse callback in your table constructor to tell tabulator where to look for the data array:
$("#example-table").tabulator({
ajaxResponse:function(url, params, response){
//url - the URL of the request
//params - the parameters passed with the request
//response - the JSON object returned in the body of the response.
return response.data; //return the data property of a response json object
},
});
Let me know if that helps
Cheers
Oli
Most helpful comment
Hey,
that is because it is returning the data array held in the data property of an object, if you have to send data in this format, then you can use the ajaxResponse callback in your table constructor to tell tabulator where to look for the data array:
Let me know if that helps
Cheers
Oli