AJAX调用后我的局部视图没有刷新

问题描述 投票:0回答:1

我遇到了无法刷新我的部分视图的问题。

我的cshtml页面页面

<script type="text/javascript">
  $(document).ready(function () {
      $('#btncreate').click(function () {
          var projectid = $("#txtprojectid").val();
          $.ajax({
              url: '/Projects/CreateFinanceItems?pid=' + Id,
              datatype: 'json',
              type: "POST",
              success: function (response) {
                  alert("record created successfully");
                  if (response != null) {
                      window.close();
                      refreshpartial();
                  }
              }
          })
      });

      function refreshpartial()
      {
          $.ajax({
              url: '/Projects/PartialItem?id=' + "Test",
              datatype: 'json',
              success: function (response) {
                  $("#displayproContainer").html(response);
              },
              error: function (xhr, ajaxOptions, thrownError) {
              }
          })
      }
    });        
    </script>

我可以看到记录已成功创建警报消息,但是当它进入refreshpartial方法时,我的partialview不会使用添加的数据刷新。我将警报设置为不会触发的成功功能。

Partialview DIV ID #displayproContainer

$("#displayproContainer").html(response);

控制器代码

  [OutputCache(Duration = 0)]
        public PartialViewResult PartialItem(string id)
        {
            // Logic to Insert data
            return PartialView(viewModel);
        }

我在这里想念什么?

asp.net-mvc
1个回答
0
投票

这是执行此操作的方法。

© www.soinside.com 2019 - 2024. All rights reserved.