trying to return dictionary as jsonresult, number of elements in dictionary > 3.6k; my code:
$('#go').click(function () {
$("#content").empty().html('<img src="Content/loading.gif" style="top:100px;left:100px;"/>');
$.ajax({
type: 'POST',
开发者_运维技巧 url: '<%= Url.Action("LoadContent","Home") %>',
async: true,
data: {
block: $('input[name=block]:checked').attr('value'),
type: $('input[name=type]:checked').attr('value'),
begin: $('#begindate').attr('value') + " " + $('#begintime').attr('value'),
end: $('#enddate').attr('value') + " " + $('#endtime').attr('value')
},
dataType: 'json',
success: function (response) {
alert(response);
$.plot($("#content"), repsonse);
}
});
});
and server side:
public JsonResult LoadContent(string block,string type,string begin,string end) {
List<FinalResult> result = Core.LetThePartyBegin(DateTime.Parse(begin), DateTime.Parse(end), block);
Dictionary<DateTime, double> returnValue = new Dictionary<DateTime, double>();
result.ForEach(p =>
p.Result.ForEach(q => returnValue.Add(p.Datetime + new TimeSpan(0, 0, q.Number), q.W)));
return Json(returnValue);
}
so, Json(returnValue) contains 3600 values, and i'm getting error 500 internal server error; if i set Json(returnValue.Take(100)) it works. is there any constraint on size of jsonresult?
There is a max size for an ajax response. (I'm not sure but I think it's 4M)
Maybe your intended response might be larger than this maximum. This would also explain why it works when you return a subset smaller than the max size.
Check the detailed error message
One of you dates is not parsing. Are you sure they are all valid?
精彩评论