Unable to load my JSON data into datatables using ajax
Unable to load my JSON data into datatables using ajax
I am receiving following json data in my ajax code. I am trying to add the received data into datatables but they are not getting inserted into tables.
My received data is:
[
{
"rowNumber": 1,
"mailingID": 3,
"firstname": "Brian",
"lastname": "Fairhurst",
"organization": "Florida State University",
"city": "Tallahassee",
"state": "FL"
},
{
"rowNumber": 2,
"mailingID": 3,
"firstname": "Bruce",
"lastname": "Ballister",
"organization": "Apalachee Regional Planning Council",
"address1": "20776 Central Avenue East",
"address2": "Suite 1",
"city": "Blountstown",
"state": "FL",
"zip": 32424
}
]
and my ajax code snippet is:
$.ajax({
type : "POST",
url : "getLabels.jsp",
data : "mailingID=" + selectedValue, // posCodeSelected
success : function(data) {
var dataset= data;
console.log(dataset); /* this logs the above dataset*/
$('#printIDs').dataTable( {
"ajax": response,
"columns": [
{ "data": "rowNumber" },
{ "data": "mailingID" },
{ "data": "firstname" },
{ "data": "lastname" },
{ "data": "organization" },
{ "data": "address1" },
{ "data": "address2" },
{ "data": "address3" },
{ "data": "address4" },
{ "data": "city" },
{ "data": "state" },
{ "data": "" }
]
} );
});