How Can I Render a Partial View via AJAX?

后端 未结 1 1464
北海茫月
北海茫月 2021-01-13 18:57

This should be relatively simple for the MVC experts out there, but I\'m still learning the ropes.

  • I have a View which is not strongly-typed, simply View
相关标签:
1条回答
  • 2021-01-13 19:44

    You can use jQuery to request html as well as Json from the controller. So your jQuery could look like this:

    $.get(action, null, function(data){
      $('#someDiv').html(data);
    }, 'html');
    

    and you controller could return:

    return PartialView("SomePartial", Model)
    

    And the html would be rendered to the screen

    0 讨论(0)
提交回复
热议问题