0
我有我的aspx網頁製作的平板JSON字符串..jQuery的數據表請求的未知參數「0」行「0」列「0」
[{"UserName":"ABENS"},{"UserName":"AILPAL"},{"UserName":"ANDREW.GUILLERMO"},{"UserName":"ANGELO.MARCOS"},{"UserName":"ANITADL"},{"UserName":"ARIELG"},{"UserName":"BERLYNM"},{"UserName":"BRAINS"},{"UserName":"DENCHU"},{"UserName":"DON"},{"UserName":"IANB"},{"UserName":"JEANIV"},{"UserName":"JEL"},{"UserName":"JERRY.SALON"},{"UserName":"JHENG"},{"UserName":"JOELP"},{"UserName":"JOHN.BEDUYA"},{"UserName":"JOHNROL"},{"UserName":"JULIUSB"},{"UserName":"JUNNILR"},{"UserName":"LEAHR"},{"UserName":"LEONILAV"},{"UserName":"LIEZELC"},{"UserName":"MAILA"},{"UserName":"MARITA"},{"UserName":"MAYBEL"},{"UserName":"MUSHI"},{"UserName":"NELMARA"},{"UserName":"NOELMAGOS"},{"UserName":"NORMAN.HUDENCIAL"},{"UserName":"PAUL"},{"UserName":"RALPH.DELROSARIO"},{"UserName":"REYBALAD"},{"UserName":"RODELLA"},{"UserName":"SGUOTANA"},{"UserName":"TESTA"},{"UserName":"THERESAP"},{"UserName":"VANESSAF"},{"UserName":"VIRGINIAP"}]
我已經宣佈以下的HTML ..
<table id="tblUserAccountsManagement" class="display" cellspacing="0">
<thead>
<tr>
<th>UserName</th>
</tr>
</thead>
</table>
我有以下的jQuery的...
$(document).ready(function() {
var tbl = $('#tblUserAccountsManagement').DataTable({
"ajax": {
"url": "AccountsManagementJSON.aspx",
"dataSrc": ""
},
"columns": [
{ "data": 'UserName' }
],
autofill: true,
select: true,
responsive: true,
buttons: true,
length: 10,
});
});
爲何仍輸出錯誤「申請行未知參數‘0’‘0’列'0'「?我已閱讀everything後跟每個troubleshoot都有,確保html和jQuery定義完好無損。爲什麼它仍然沒有工作?
我不明白的是,我在這裏嘗試過這before它工作。我只需要添加dataSrc: ""
就可以了。我遵循我之前的例子來寫這封信,現在它不起作用。
奇怪的是,它確實顯示了行數(像JSON中的39行)但它不會顯示內容。這是爲什麼?
您可以提供JSON的例子嗎?可能無法正確格式化數據表? – jonmrich
該示例包含在問題中。這是一個平面陣列。我遵循這裏的指南: https://datatables.net/examples/ajax/custom_data_flat.html –
這很奇怪,我已經用你的數據製作了一個JSFiddle(https://jsfiddle.net/annoyingmouse/da2vbL1L/ ),一切似乎都正常工作。只是一個想法,但你的服務器沒有像添加物料清單一樣奇怪嗎?可能不是,但也許看看你的ajax的反應和檢查? – annoyingmouse