我有这个控制器方法:
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);
}
Run Code Online (Sandbox Code Playgroud)
在客户端,有这个jQuery脚本:
$("#radio1").click(function () {
$.ajax({
url: "/Home/List",
dataType: "json",
data: { number: '1' },
success: function (data) { alert(data) },
error: function (xhr) { alert(xhr.status) }
});
});
Run Code Online (Sandbox Code Playgroud)
我总是得到一个错误代码500.问题是什么?
谢谢