日期:2014-05-17  浏览次数:20407 次

MVC3的AJAX请求为什么返回集合的长度是1,求解!!!!!!
前台这样写的
  $.ajax({
  type: 'Post',
  url: '@Url.Action("GetJSON", "Article")',
  dataType: "json",
  success: function (data) {
  alert(data.length);
  $.each(data, function (i, item) {
  alert(item["CatalogId"]);
  });
  }
  });

后台这样
[HttpPost]
  public ActionResult GetJSON()
  {
  return this.Json(new Catalog().GetAllContents());//GetAllContents返回的是一个集合
  }


我这样写的返回对不对?怎么打印 alert(data.length);这个是1,GetAllContents()里面返回的是长度为24个集合
这样传过去,就变成1了,需要怎么修改

------解决方案--------------------
1 应该是1个object吧
------解决方案--------------------
后台这样
[HttpPost]
public JsonResult GetJSON()
{
return this.Json(new Catalog().GetAllContents());//GetAllContents返回的是一个集合
}