How do I use a Controller Action to refresh the model without navigation?

前端 未结 2 1340
终归单人心
终归单人心 2021-01-12 03:36

I have a MVC 5 website that displays log file entries in a grid and provides a search capability. I have both the search criteria and the grid.mvc grid on the Index page. Wh

2条回答
  •  迷失自我
    2021-01-12 04:14

    You will need to return your model. You can keep your view and extract via javascript the model from the view, or you can have a JsonResult and return only the serialized string.

    From javascript side, trigger this from a button or the event of your wish.

    var params = ["data","data", "data"];
    
    $.ajax({
      type: "POST",
      url: /ProcessLogEntries,
      data: params,
      success: function(data, statusRespoonse, xhr){
       //extract your model from data or return your model via jsonresult by changing the Controller's return type.
    
        yourModel = data;
       },
      dataType: "json"
    });
    

提交回复
热议问题