Mapping json
Mapping json
classic12
Posts: 228Questions: 60Answers: 4
in DataTables
Hi guys,
I have the following test data coming back from an ajax call
[{"animID":"1","title":"Marina Gate I \u2013 Facilities","url":"<iframe width=\"100%\" height=\"700\" frameborder=\"0\" id=\"landingmap\" src=\"https:\/\/my.matterport.com\/show\/?m=bkh2QEaDmuu&play=1&brand=0&help=0&mls=0&qs=1\"><\/iframe>","status":"active"},{"animID":"2","title":"Two Bedroom Show Apartment (Type 2F)","url":"<iframe width=\"100%\" height=\"700\" frameborder=\"0\" id=\"landingmap\" src=\"https:\/\/my.matterport.com\/show\/?m=H26hek9kPst&play=1&brand=0&help=0&mls=0&qs=1\"><\/iframe>","status":"active"}]
I am using the following code but I am not getting any data showing.
dataReturned = [];
getIframes=function(){
req = Ajax("http://www.xxx.com/getIframes.php", "GET", '',iframesReturned);
}
function iframesReturned() {
dataReturned =[];
if (req.status == 200) { //success
alert('data back '+ req.responseText);
//dataReturned = JSON.parse(req.responseText);
dataReturned = req.responseText;
//alert(dataReturned);
//alert(dataReturned[0][0].title);
$("#dtIframes").DataTable().destroy();
$('#dtIframes').empty();
data = dataReturned;
tableIframes = $('#dtIframes').DataTable( {
columns: [
{
data: "title",
title : ' Title ',
width : '150px'
}
]
})
}
}
Button1.onclick=function(){
// get the iframe data and show in datatable.
getIframes();
}
cheers
Steve Warby
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You haven't configured any options for Datatables to get the data. Looks like you will need
data
, for example:Kevin
Whoops, some late nights
Cheers
Steve Warby
I am now getting
DataTables warning: table id=dtIframes - Requested unknown parameter 'title' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4
Can you use the debugger on your table please?
Allan
I got it working by using a different php method.
Cheers
Steve Warby