我如何重新加载页面,但有一个额外的参数(asp.net core 2.0)

时间:2018-01-15 12:57:41

标签: javascript jquery url asp.net-core-2.0

我之前发过一个问题,但我只是模糊地解释了我的问题而且我删除了它并启动了另一个问题。我正在尝试实现一个基于查询的过滤器,其中用户填写(属性,运算符,值)组。该页面有一个分页的元素列表(视图的模型是这个列表),它们都属于某个其他实体,这个实体在这里并不重要,通过作为参数传递的Id链接到它。控制器操作如下所示:

public async Task<IActionResult> Index(Guid ideaId,
                      int? page, 
                      List<FilterItemViewModel> data)
{

    //here I take the data, and filter the elements and then return them;
    //the 'data' list can be empty and indeed it is when you first access the page; 
    //in that case I just return all elements that have their 'IdeaId' 
    //field equal to the parameter 'ideaId'

    return View(await PagedList<FeatureViewModel>.CreateAsync(model.AsNoTracking(), 
                      page ?? 1, 
                      int.Parse(_configuration["Pagination:ItemsPerPage"])));
}

关于过滤器本身,用户可以根据需要添加任意数量的过滤器组。按下'过滤器'后,我在javascript中收集他输入的所有值,我把它们放在一个数组中,这就是我坚持的部分。我需要将其发送到Index操作并使用新信息重新加载。我试过像这样的ajax:

$.ajax({
    url: '/Feature/Index',
    data: finalParams,
    type: 'POST',
    success: function (response) {
        //response here is the HTML and scripts and style of the page and it
        //returns what it should after filtering but I need to access the page itself        
    },
    error: function () {
        alert("pffff");
    }
});

请注意,'finalParams'是一个对象,其字段名为'ideaId','page','data',其中'ideaId'和'page'取自当前位置,data是我收集的数组用户输入。

如何访问该回复返回的页面?或者有什么方法可以将数据发送到控制器并返回不同的设置吗?

0 个答案:

没有答案
相关问题