所以我有以下代码有效:
var a = $("#sample_1").dataTable().fnAddData( [
domEle['AGENCY_NAME'],
domEle['ADVERTISER_NAME'],
domEle['CAMPAIGN_NAME'],
domEle['STRATEGY_NAME'],
domEle['IMPRESSIONS'],
domEle['CLICKS'],
domEle['PC_CONVERSIONS'],
domEle['PV_CONVERSIONS'],
domEle['ADJ_PV_CONVERSIONS'],
domEle['eCPM'],
domEle['eCPA'],
domEle['eCPC'],
domEle['MEDIA_COST'],
domEle['TOTAL_SPEND'],
]);
但是,我想按 AJAX 中返回的顺序显示列,所以我想将其更改为:
var a = $("#sample_1").dataTable().fnAddData( [
$.each(data['columns_order'], function(key, value){
domEle[data['columns_order'][key]['fieldy']],
});
]);
但我不断收到以下错误"Uncaught SyntaxError: Unexpected token ) "
。