【发布时间】:2016-04-22 20:02:53
【问题描述】:
大家好,我有以下 JSON 来自使用 AJAX 的 Web 服务:
{
"data": [
[
"11/11/2014 3:02:37 PM",
"4/13/2015 8:26:37 AM",
"032650147",
"NULL",
"Web Site Problems",
"NULL",
"New",
"6230.758742407"
],
[
...etc etc....
]
]
}
我正在动态创建 HTML 表格,如下所示:
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Contact Date Time</th>
<th>Last Update Date Time</th>
<th>Member ID</th>
<th>Operator NTID</th>
<th>Question</th>
<th>Redirect Email Address</th>
<th>Status</th>
<th>Receipt Date</th>
</tr>
</thead>
</table>
而我用来在表中显示返回数据的 JavaScript 是:
$.ajax({
type: "POST",
crossDomain: true,
url: "complete.aspx/getMemberEmailsDBData",
beforeSend: function (xhrObj) {
xhrObj.setRequestHeader("Content-Type", "application/json");
},
data: {},
dataType: "json",
success: function (data) {
console.log(data.d);
$('#example').DataTable({
data: data.d,
columns: [
{ title: "ContactDateTime" },
{ title: "LastUpdateDateTime" },
{ title: "MemberID" },
{ title: "OperatorNTID" },
{ title: "QuestionArea" },
{ title: "RedirectEmailAddress" },
{ title: "Status" },
{ title: "ReceiptDate" }
]
});
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
console.log(XMLHttpRequest);
}
});
加载页面后,它不断给我弹出警报,告诉我:
DataTables 警告:表 id=example - 请求的未知参数“1” 对于第 0 行第 1 列。有关此错误的更多信息,请参阅 http://datatables.net/tn/4.
有人看到我缺少的东西来解决这个问题吗?
【问题讨论】:
-
console.log(data.d);output 是什么意思? -
我在上面的 OP 中发布的 JSON。
标签: jquery json ajax vb.net datatables