我有这样的控制方法:ASP.NET MVC JsonResult返回500
public JsonResult List(int number)
{
var list = new Dictionary<int, string>();
list.Add(1, "one");
list.Add(2, "two");
list.Add(3, "three");
var q = (from h in list
where h.Key == number
select new
{
key = h.Key,
value = h.Value
});
return Json(list);
}
在客户端,有这样的jQuery脚本:
$("#radio1").click(function() {
$.ajax({
url: "/Home/List",
dataType: "json",
data: { number: '1' },
success: function (data) { alert(data) },
error: function (xhr) { alert(xhr.status) }
});
});
我总是得到一个错误代码500怎么了问题?
谢谢
这适用于ASP.NET MVC 2,正确吗? JsonRequestBehavior.AllowGet要求从版本2开始。 – JustinStolle 2010-06-24 22:49:46