所以我有以下代码可以使用:
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 ) "
。
答案 0 :(得分:0)
我不确定,但我认为问题是,最后,在domEle之后[data ['columns_order'] [key] ['fieldy']]
答案 1 :(得分:0)
var a = $("#sample_1").dataTable().fnAddData({
$.each(data['columns_order'], function(key, value){
domEle[data['columns_order'][key]['fieldy']],
});
});
复制粘贴上面的代码。您错过了代码中的一些括号