2011-02-24 64 views
0

试图将字典返回为jsonresult,字典中的元素个数> 3.6k; 我的代码:asp mvc 2返回json结果

$('#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); 
      } 
     }); 
    }); 

和服务器端:

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); 
    } 

因此,JSON(的returnValue)包含3600个值,并且我得到错误500内部服务器错误; 如果我设置JSON(returnValue.Take(100))它的工作原理。 对jsonresult的大小是否有任何约束?

+0

你能提供返回的json的start20和end 20个字符,它可能有助于定位错误。 – 2011-02-24 11:57:01

+0

怎么样?它的简单字典,不知道要显示什么 – eba 2011-02-24 12:00:13

+0

错误的细节是什么? – roryf 2011-02-24 12:38:53

回答

1

ajax响应的最大尺寸。 (我不确定,但我认为它是4M)

也许您的预期响应可能大于此最大值。这也可以解释为什么当你返回一个小于最大尺寸的子集时它会工作。

查看详细错误信息

0

其中一个日期不解析。你确定他们都是有效的吗?