javascript – 错误从MVC加载数据Jtable?

我在 codeproject.com/script/Articles/ArticleVersion.aspx?aid=277576&av=419297阅读了有关mvc的jtable的文章

我试试看.但是在运行时,我得到错误在与服务器通信时发生错误.
请看我的代码.在控制器中

   [HttpPost]
        public JsonResult LocalList(int jtStartIndex, int jtPageSize, string jtSorting)
        {
            try
            {
                string localCount = db.Database.SqlQuery<string>("Select Count(*) FROM Location").ToString();
                IEnumerable<LOCATION> query = db.LOCATIONs;
                if (jtSorting.Equals("LOCATION_ID ASC"))
                {
                    query = db.LOCATIONs.OrderBy(e => e.LOCATION_ID).Skip(jtStartIndex).Take(jtPageSize).ToList();
                }
                else
                {
                    query = db.LOCATIONs.OrderBy(e => e.LOCATION_ID).Skip(jtStartIndex).Take(jtPageSize).ToList();
                }
                return Json(new { Result = "OK", Records = query, TotalRecordCount = int.Parse(localCount) });
            }
            catch (Exception ex)
            {
                return Json(new { Result = "ERROR", Message = ex.Message });
            }
        }

并在视图中

$('#div_local').jtable({
            title: 'List Location',
            paging: true, //Enable paging
            pageSize: 10, //Set page size (default: 10)
            sorting: true, //Enable sorting
            defaultSorting: 'LOCATION_ID ASC', //Set default sorting
            actions: {
                listAction: 'HomeController/LocalList'
            },
            fields: {
                AREA_ID: {
                    key: false,
                    list: false,
                    create: false
                },
                LOCATION_ID: {
                    key: true,
                    list: false,
                    create: false
                },
                LOCATION_NAME: {
                    title: 'Name'
                },
                LOCATION_DES: {
                    title: 'Des'
                }
            }
        });

        $('#div_local').jtable('load');

在这里,所有文件脚本和样式表都可以.当我看到登录chrome时,我找到了

Request URL:http://localhost:27508/HomeController/LocalList?jtStartIndex=0&jtPageSize=10&jtSorting=LOCATION_ID%20ASC
Request Method:POST
Status Code:404 Not Found

你能告诉我这里发生了什么错误或错误吗?以及如何解决它.
谢谢你们.

最佳答案 看起来listAction指向一个不存在的url(由于HTTP错误404).

您是否可以使用日志中的请求URL手动下载json?

点赞