我有我的aspx网页制作的扁平Json字符串..
[{"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: ""
就可以了。我按照前面的例子写了这封信,现在它不起作用。
奇怪的是,它确实显示了行数(39行,如JSON中所示)但它不会显示内容。那是为什么?
答案 0 :(得分:1)
我已经解决了这个问题:我已经使用aoColumns
和mData
进行了此设置(带有MasterPages的Webforms)。
现在可以使用以下内容:
$(document).ready(function () {
var tbl = $('#tblUserAccountsManagement').DataTable({
"ajax": {
"url": "AccountsManagementJSON.aspx",
"dataSrc": ""
},
aoColumns: [
{ mData: 'UserName' }
],
autofill: true,
select: true,
responsive: true,
buttons: true,
length: 10,
});
});