Asp.net mvc 如何在asp.net mvc中通过ajax更新特定的div数据

Asp.net mvc 如何在asp.net mvc中通过ajax更新特定的div数据,asp.net-mvc,asp.net-mvc-ajax,Asp.net Mvc,Asp.net Mvc Ajax,如何在asp.net mvc中通过ajax更新特定的div数据您可以查看以下属性: 控制器: public ActionResult SomeAction() { // you could return a PartialView here if you need more complex HTML fragment return Content("<span>some content</span>", "text/html"); } public Ac

如何在asp.net mvc中通过ajax更新特定的div数据您可以查看以下属性:

控制器:

public ActionResult SomeAction()
{
    // you could return a PartialView here if you need more complex HTML fragment
    return Content("<span>some content</span>", "text/html");
}
public ActionResult SomeAction()
{
//如果需要更复杂的HTML片段,可以在此处返回PartialView
返回内容(“某些内容”、“文本/html”);
}
视图:


另一种方法可能是从控制器返回部分视图,并将生成的html放入div中

    public ActionResult jQueryTagFilter(string filterBy)
    {
      //Do stuff
      return PartialView("TagList", tags);
    }
然后在你的html中

    $.post("/Admin/jQueryTagFilter", { filterBy: filter }, function(newUserListHTML) {
        $("#divTags").fadeOut(300, function() {
          $"#divTags").innerHTML = newUserListHTML;
          });

        $("#divTags").fadeIn(300);
    });

你能提供一份example@Fraz,我添加了一个示例。
    $.post("/Admin/jQueryTagFilter", { filterBy: filter }, function(newUserListHTML) {
        $("#divTags").fadeOut(300, function() {
          $"#divTags").innerHTML = newUserListHTML;
          });

        $("#divTags").fadeIn(300);
    });