0
У меня есть PHP-файл (ads.php), который возвращает массив JSON объект, состоящий из набора записейJson объект массива DataTable
а массив
[{"hea":{"0":"Kidney Stone Removal"},"id":{"0":"16282238572"},"desc":{"0":"Get treated at top kidney center"},"desc2":{"0":"Take a free advice from our experts"},"url":{"0":"www.ainuindia.com"},"cli":{"0":"1"},"cpc":{"0":"0"},"con":{"0":"0"},"cost":null,"ctr":{"0":"5.26%"},"imp":{"0":"19"},"ap":{"0":"2.2"}}]
И моя ява Srcript является
$("#example1").dataTable();
$("#groupid").change(function(){
var oTable = $('#example1').dataTable();
var grpvalue=$('#groupid').val();
$.ajax({
type:"post",
dataType : 'json',
url:"pages/ads.php",
data:"adgroup="+grpvalue,
success: function(s) {
oTable.fnClearTable();
for(var i = 0; i < s.length; i++) {
oTable.fnAddData([
s[i]['hea'],
s[i]['id'],
s[i]['desc'],
s[i]['desc2'],
s[i]['url'],
s[i]['cli'],
s[i]['cpc'],
s[i]['con'],
s[i]['cost'],
s[i]['ctr'],
s[i]['imp'],
s[i]['ap']
]);
}
}
});
});
И таблица данных Html является
<table id="example1" class="table table-bordered table-striped num-right-alignct">
<thead>
<tr>
<th style="text-align: center;">Ad Headline</th>
<th style="text-align: center;">Ad ID</th>
<th style="text-align: center;">Ad Description 1</th>
<th style="text-align: center;">Ad Description 2</th>
<th style="text-align: center;">URL Appeared</th>
<th style="text-align: center;">Clicks</th>
<th style="text-align: center;">CPC</th>
<th style="text-align: center;">Conversions</th>
<th style="text-align: center;">CTR %</th>
<th style="text-align: center;">Impressions</th>
<th style="text-align: center;">Avg Pos</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Когда я извлекаю эти значения, все данные вставляются только в первый столбец, а не в другие столбцы, как я могу поместить эти значения в таблицу данных со всеми заполненными столбцами и строками?