<script>
function Getdata() {
$.ajax({
type: "POST",
url: "WebForm1.aspx/Getdata",
contentType: "application/json; charset=utf-8",
data: {}, //无参数
dataType : "json", //返回数据形式为json
success: function (result) {
var strJson = result.d;
alert(strJson);
// var jsonObj = eval(strJson);
// var html = '';
//for (var i = 0; i < jsonObj.length; i++) {
// html += '' + jsonObj[i].TS_ErrorCode + '' + jsonObj[i].TM_ParmName + ' ' + jsonObj[i].TM_ParmDESC + '' + jsonObj[i].TM_ParmFile + '' + jsonObj[i].TP_TestPattemName + '' + jsonObj[i].TP_TestPattemCode + '' + jsonObj[i].TS_TestBroadID + '';
//};
// $("#aa").append(html);
}
});
}
</script>
public static string Dtb2Json(DataTable dtb)
{
JavaScriptSerializer jss = new JavaScriptSerializer();
System.Collections.ArrayList dic = new System.Collections.ArrayList();
foreach (DataRow dr in dtb.Rows)
{
System.Collections.Generic.Dictionary<string, object> drow = new System.Collections.Generic.Dictionary<string, object>();
foreach (DataColumn dc in dtb.Columns)
{
drow.Add(dc.ColumnName, dr[dc.ColumnName]);
}
dic.Add(drow);
}
//序列化
return jss.Serialize(dic);
}
这样序列化出来的json太大,ajax获取后报错,只取少部分就能正常返回,请问怎么解决呢