数据表“无法读取属性sError of null”

时间:2013-09-20 15:47:35

标签: asp.net-mvc datatables

我对数据表很新,我需要使用AJAX服务器处理将数据加载到表中。

我尝试使用GET请求,但收到了404 not found错误,并且URL不完整(URL中缺少操作名称)。

我读了一篇关于推荐使用POST而不是GET请求的类似问题的帖子。使用GET我现在收到“无法读取属性sError of null”,并且无法弄清楚会发生什么。

我无法在控制器中进行调试,因为它甚至没有到达那里。

这是我的datatables对象的初始化代码:

 oTable = $('#solutionsTable').dataTable({
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        "bSort": false,
        "oLanguage": {
            "sSearch": "Search all columns:"
        },
        "bProcessing": true,
        // "bDeferRender": true,
        "bServerSide": true,
        "bAjaxSource": "AJAXGetUserData",
        "sServerMethod": "POST"
    });

这是控制器动作(尽管它没有到达那里)

 [HttpPost]
    public ActionResult AJAXGetUserData(jQueryDataTableParamModel param)
    { 
        var allUsers = CMSHelper.GetUsers(countries: User.IsInRole("Account Admin") ? CMSHelper.GetAdminCountries(User.Identity.Name).Select(c => c.Key).ToList() : null);
        var result = from u in allUsers 
                     select new string[] {Convert.ToString(u.userId), u.userName, u.roleId.ToString(), u.type, u.isActive.ToString(), u.firstName, u.lastName, 
                     u.email, u.phone, u.Postcode, u.Street, u.Street, u.company, u.jobId.ToString(), u.job, u.country, u.countryName, u.City, u.LoginsNum.ToString(), 
                     u.LastLogin.ToShortDateString()};

        return Json(new
        {
            sEcho = param.sEcho,
            iTotalRecords = 97,
            iTotalDisplayRecords = 3,
            aaData = result
        }, JsonRequestBehavior.AllowGet);
    }

1 个答案:

答案 0 :(得分:0)

它实际上返回了404 Not found异常,由于我的操作使用了POST请求而我的Home Controller中的PageNotFound操作仅针对GET请求,因此未被捕获。虽然我无法弄清楚为什么我得到了未找到的回复

相关问题