小编Pet*_*eti的帖子

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);
}
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.问题是什么?

谢谢

asp.net-mvc jquery json

8
推荐指数
1
解决办法
7572
查看次数

标签 统计

asp.net-mvc ×1

jquery ×1

json ×1