【发布时间】:2014-11-19 01:07:09
【问题描述】:
在返回超过 40,000 条记录的 web 服务的 web.config 中,我为 json 序列化设置了 maxlength
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000"/>
</webServices>
</scripting>
</system.web.extensions>
function BindInfoDataTableServerSide()
{
var oTable = $('#example').dataTable({
"sScrollY": "250px",
'bPaginate': true,
"bProcessing": true,
"bFilter": false,
"bServerSide": true,
//"aoColumns": [null, null, { "bSortable": false }, { "bSortable": false}, null, null, null, null],
/* "aoColumns": [
{ "sTitle": "ScreenId" },
{ "sTitle": "RunId" },
{ "sTitle": "RecordType" },
{ "sTitle": "TrackerKey" },
{ "sTitle": "SeqNo" },
{ "sTitle": "TRSeqNo" },
{ "sTitle": "TestParam" },
{ "sTitle": "ParamValue" },
]
,*/
"sAjaxSource": "../SocWebService.asmx/LoadMidasData",
"sAjaxDataProp": "aaData",
"fnServerData": function (sSource, aoData, fnCallback) { GrabData(sSource, aoData, fnCallback); }
});
}
function GrabData(sSource, aoData, fnCallback) {
$.ajax({
type: "POST",
url: sSource,
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "",
success: function (result) {
var myObject = JSON.parse(result.d);
fnCallback(myObject);
//fnCallback(result.d);
},
error: function (errMsg) {
alert(errMsg);
}
});
}
但是当记录达到 50,000 条时,我会遇到以下错误
在使用 JSON JavaScriptSerializer 进行序列化或反序列化期间。字符串的长度超过了 maxJsonLength 属性上设置的值。 Jquery 数据表网站声称它们可以显示 100 万条记录。我错过了什么吗?
【问题讨论】:
-
尝试设置
maxJsonLength="0"(0 表示无限制)或2147483644。在 -> stackoverflow.com/questions/1151987/… 中查看此问题/答案/链接