Mvc Ajax JQuery Uncaught TypeError

Mvc Ajax JQuery Uncaught TypeError,jquery,ajax,asp.net-mvc,grid.mvc,Jquery,Ajax,Asp.net Mvc,Grid.mvc,我对Grid.MVC Ajax有问题。我找到了一个使用它的项目,我正在尝试使它适应我的项目。事实上,加载网格时会出现错误 Uncaught TypeError: Cannot read property 'length' of undefined at HTMLDivElement.<anonymous> (<anonymous>:1:382) at Function.each (jquery-3.3.1.js:354) at jQuery.fn.init.each (j

我对Grid.MVC Ajax有问题。我找到了一个使用它的项目,我正在尝试使它适应我的项目。事实上,加载网格时会出现错误

Uncaught TypeError: Cannot read property 'length' of undefined
at HTMLDivElement.<anonymous> (<anonymous>:1:382)
at Function.each (jquery-3.3.1.js:354)
at jQuery.fn.init.each (jquery-3.3.1.js:189)
at jQuery.fn.init.gridmvc (<anonymous>:1:95)
at HTMLAnchorElement.gridQuestionInit (<anonymous>:8:23)
at Object.success (jquery.unobtrusive-ajax.min.js:15)
at fire (jquery-3.3.1.js:3268)
at Object.fireWith [as resolveWith] (jquery-3.3.1.js:3398)
at done (jquery-3.3.1.js:9305)
at XMLHttpRequest.<anonymous> (jquery-3.3.1.js:9548)
似乎JQuery找到了网格。如果我在这一行之后尝试,什么都不会发生。因此,我认为数据问题一定是.gridmvc()

Edit4

我解决了这个问题。在包含网格的父页面中,在网格本身之前有一个类为“grid mvc”的div。这就是为什么脚本不起作用


现在我必须修复另一个错误。找不到action GridPager,但我认为它会更容易解决。

从下面的div类中删除grid mvc

  <div class=" hidden-xs grid-mvc">
        @{
            HtmlGrid<OnlineWeb.Models.usp_Proc_Result> mvcGrid = null;
            GridMvc.Pagination.GridPager pager = new GridMvc.Pagination.GridPager();
        }

@{
HtmlGrid mvcGrid=null;
GridMvc.Pagination.GridPager pager=新建GridMvc.Pagination.GridPager();
}

我假设这些asp.net助手在前端呈现JavaScript。你能粘贴渲染的JavaScript吗?这听起来不像是一个订单问题,更像是一个缺少数据的问题,特别是一个结果(可能来自ajax调用),它应该是一个数组,但不是。@War10ck完成了。忽略class属性,因为我发现了一种显示带有asp.net帮助程序的glyphicon的好方法。此外,我真的不明白你在寻找什么,因为这些助手在网格中工作。也许ajax调用之间存在冲突?
public ActionResult GetGrid()
{
    var items = db.question.Where(x => x.statusquestion.IntituleStatusQuestion != "Supprimée").OrderByDescending(x => x.idQuestion);
    var grid = gridMvcHelper.GetAjaxGrid<question>((IOrderedQueryable<question>)items);

    return PartialView(GRID_QUESTION_PATH, grid);
}

[HttpGet]
public ActionResult GridPager(int? page)
{
    var items = db.question.Where(x => x.statusquestion.IntituleStatusQuestion != "Supprimée").OrderByDescending(x => x.idQuestion);
    var grid = gridMvcHelper.GetAjaxGrid<question>((IOrderedQueryable<question>)items, page);
    object jsonData = gridMvcHelper.GetGridJsonData(grid, GRID_QUESTION_PATH, this);

    return Json(jsonData, JsonRequestBehavior.AllowGet);
}
    <a class="glyphicon-edit" data-ajax="true" data-ajax-begin="onAjaxBegin" data-ajax-complete="onAjaxComplete" data-ajax-loading="#divLoading" data-ajax-mode="replace" data-ajax-update="#myModalBody" data-target="#myModal" data-toggle="modal" href="/Home/AfficherQuestion/28">ttttt</a>

   <a class="glyphicon-edit" data-ajax="true" data-ajax-begin="onAjaxBegin" data-ajax-complete="onAjaxComplete" data-ajax-loading="#divLoading" data-ajax-mode="replace" data-ajax-update="#myModalBody" data-target="#myModal" data-toggle="modal" href="/Home/ModifierQuestion/28">M</a>

    <a class="glyphicon-remove" data-ajax="true" data-ajax-begin="onAjaxBegin" data-ajax-complete="onAjaxComplete" data-ajax-loading="#divLoading" data-ajax-mode="replace" data-ajax-update="#myModalBody" data-target="#myModal" data-toggle="modal" href="/Home/SupprimerQuestion/28">S</a>

    <a class="glyphicon-remove" data-ajax="true" data-ajax-begin="onAjaxBegin" data-ajax-complete="onAjaxComplete" data-ajax-loading="#divLoading" data-ajax-mode="replace" data-ajax-update="#myModalBody" data-target="#myModal" data-toggle="modal" href="/Home/AfficherProposition?idQuestion=28">P</a>
    {"0":{},"1":{},"length":2,"prevObject":
{"0":
{"location":
{"href":"http://localhost:50866/Home","ancestorOrigins":{},"origin":"http://localhost:50866","protocol":"http:","host":"localhost:50866","hostname":"localhost","port":"50866","pathname":"/Home","search":"","hash":""},"jQuery110201876682714105331":1},"context":
{"location":
{"href":"http://localhost:50866/Home","ancestorOrigins":{},"origin":"http://localhost:50866","protocol":"http:","host":"localhost:50866","hostname":"localhost","port":"50866","pathname":"/Home","search":"","hash":""},"jQuery110201876682714105331":1},"length":1},"context":
{"location":
{"href":"http://localhost:50866/Home","ancestorOrigins":{},"origin":"http://localhost:50866","protocol":"http:","host":"localhost:50866","hostname":"localhost","port":"50866","pathname":"/Home","search":"","hash":""},"jQuery110201876682714105331":1},"selector":".grid-mvc"}
  <div class=" hidden-xs grid-mvc">
        @{
            HtmlGrid<OnlineWeb.Models.usp_Proc_Result> mvcGrid = null;
            GridMvc.Pagination.GridPager pager = new GridMvc.Pagination.GridPager();
        }