ASP MVC刷新局部视图网格

时间:2017-05-19 10:21:34

标签: javascript jquery asp.net ajax asp.net-mvc

我正在尝试在更改记录后刷新部分视图网格。 我有一个用户可以点击的按钮,而不是更改网格中的一行。但是这没关系。我必须手动刷新页面才能看到修改。现在我想我可以创建一个新的JavaScript Ajax函数来实现这一点。因此,在用户按下按钮后,它将加载函数RefreshGrid

JavaScript功能:

function RefreshGrid() {

    var numberPlate = $("#NumberPlate").val();

    if (numberPlate) {
        $.ajax({
            type: 'get',
            url: appPath + '/Service/Grid',
            data: { numberPlate: numberPlate },
            success: function (response) {
                $("#Grid").html(response);
            },
            error: function (response) {
                $("#dialog .modal-body").html(msgErrorDuringRequest);
                $("#dialog #dialog-title").html(errorTitle);
                $("#dialog").modal("show");

            }
        });
    }
}

现在是控制器

public ActionResult Grid(string numberPlate)
        {
            IList<ServiceOrder> services = ServiceRepository.Services(numberPlate);
            return PartialView("_Grid", services);
        }

由于某种原因,它正在返回错误函数

error: function (response) {
                $("#dialog .modal-body").html(msgErrorDuringRequest);
                $("#dialog #dialog-title").html(errorTitle);
                $("#dialog").modal("show");

            }

但我不知道哪里出错了。不能想象它是在控制器中,因为我在其他地方有一个熟悉的功能,它完美无缺,但也许我错过了一些东西。 enter image description here

Appears that it's going to the right controller

1 个答案:

答案 0 :(得分:2)

尝试代码: 删除所有的jquery代码,仅在代码下面使用RefreshGrid函数

LEFT JOIN
相关问题