【问题标题】:Asp.net Core 3.1 - open the view with Ajax?Asp.net Core 3.1 - 用 Ajax 打开视图?
【发布时间】:2021-07-07 12:47:14
【问题描述】:

没有错误但视图不显示?

jQuery :

  $('#edit_button').on("click", function () {
        var instance = $('#jstree').jstree("get_selected");
      
        if (instance != 0) {
            $.getJSON("/AdminPanel/Category/EditMainCategory/" + instance);
        } else {
            swal("choose category");
            return false;
        }

    });

控制器:

 public IActionResult EditMainCategory(Guid Id)
    {
        var maincategory = _admin.GetCategoryById(Id);
        return View(maincategory);
    }

【问题讨论】:

标签: c# jquery asp.net ajax asp.net-core


【解决方案1】:

你可以试试这个

if(instance != 0)
{
 window.location.href = '/AdminPanel/Category/EditMainCategory' +instance
}

我假设该实例是您在 EditMainCategory 函数上的 id 参数

【讨论】:

    猜你喜欢
    • 2020-07-22
    • 1970-01-01
    • 2021-07-01
    • 2021-02-06
    • 2021-07-16
    • 1970-01-01
    • 2021-08-08
    • 1970-01-01
    • 2021-05-30
    相关资源
    最近更新 更多