AJAX - Strange comportement

AJAX - Strange comportement

gchicoyegchicoye Posts: 2Questions: 0Answers: 0

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

  • kthorngrenkthorngren Posts: 21,488Questions: 26Answers: 4,980

    You may need to change var data = result; to var data = JSON.parse(result);. If that doesn't work please provide the JSON data.

    Kevin

  • gchicoyegchicoye Posts: 2Questions: 0Answers: 0

    Works perfectly!
    Thanks a lot!

This discussion has been closed.