AJAX - Strange comportement
AJAX - Strange comportement
Hi,
I've written the following JS function in order to create a datatable.
$(function(){
$.ajax({
url: "script/getdatabuyertables.php",
datatype:"json",
success:function(result){
var data = result;
$('#buyertable').DataTable({
data: data,
columns:[
{data:"Buyer"},
{data:"Revenue"},
{data:'Var Revenue'},
{data:'Impressions'},
{data:'Var Imp'},
{data:'ECPM'},
{data:'Var ECPM'}
]
})
}
});
});
The following alert pops up:"DataTables warning: table id=buyertable - Requested unknown parameter 'Buyer' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4"
The strange thing is that I've tested the output of my php script, by putting it into a test.json file, and it worked perfectly...
So I've got no clue about what is happening...
Gabriel
Replies
You may need to change
var data = result;
tovar data = JSON.parse(result);
. If that doesn't work please provide the JSON data.Kevin
Works perfectly!
Thanks a lot!