title: How can I refresh my razor view on AJAX post
body: <p>Helo all,</p>
  <p>I am able to post to controller using ajax.post, but on success how can I make my view refresh with new data.</p>
  <p>Do I need to usn @Html.BeginForm to do this?</p>
  <p>This is my view.</p>
  <pre><code>&lt;div&gt;
      &lt;p&gt;Order lines allocates to &lt;b&gt;@Model.Name (@Model.Code) &lt;/b&gt;
  &lt;/div&gt;
  
  @if (Model.OrderLineAllocations.Any())
  {
      
      @grid.GetHtml(
               columns: grid.Columns(
                   grid.Column(header: &quot;Dispatched&quot;, style: &quot;row-selector&quot;, format: @&lt;text&gt;&lt;input name=&quot;chkSelected&quot; class=&quot;myCheckbox&quot; onclick=&quot;expandableEvent(this)&quot; type=&quot;checkbox&quot; value=&quot;@item.IdAllocation&quot; /&gt;&lt;/text&gt;),
                   grid.Column(header: &quot;Order Ref&quot;, format: item =&gt; item.OrderLineItem.OrderLine.Order.OrderRef)
                   ),
               tableStyle: &quot;expandable-table&quot;,
               rowStyle: &quot;expandable-master-row&quot;,
               htmlAttributes: new { id = &quot;gridLineAllocations&quot; })
      &lt;br /&gt;
      &lt;input type=&quot;hidden&quot; id=&quot;hidUnselectedValues&quot; name=&quot;hidUnselectedValues&quot; /&gt;
      
      &lt;input type=&quot;submit&quot; name=&quot;action&quot; value=&quot;Dispacth&quot; id=&quot;btnDispacth&quot; /&gt;
      &lt;input type=&quot;submit&quot; name=&quot;action&quot; value=&quot;Revert&quot; id=&quot;btnRevert&quot; /&gt;
      
  }
  else
  {
      @Html.Raw(&quot;No records found....&quot;);
  }
  </code></pre>
  <p>And this is my ajax post</p>
  <pre><code>$(document).ready(function() {
      unSelected = [];
      $(&quot;#btnDispacth&quot;).click(dipatchAllocations);
      $(&quot;#btnRevert&quot;).click(revertAllocations);
  });
  
  function dipatchAllocations() {
      var objInputEmail = $(&quot;#hidUnselectedValues&quot;);
  
      if (objInputEmail != null) {
          var id = objInputEmail.val();
          if ((id != null) &amp;&amp; (id != &quot;&quot;)) {
              $.ajax({
                  type: 'POST',
                  url: '/Batch/GetData',
                  data: '{ &quot;allocationId&quot; : &quot;' + id + '&quot;,&quot;batchId&quot; : &quot;' + @Model.Id + '&quot; }',
                  contentType: &quot;application/json; charset=utf-8&quot;,
                  //contentType:&quot;application/x-www-form-urlencoded&quot;,
                  traditional: true,
                  success: subscribed,
                  error: errorInSubscribing
              });
          } else {
              alert('Please enter a valid email address in order to subscribe.');
          }
      }
  };
  </code></pre>
  <p>This is my controller action</p>
  <pre><code>[HttpPost]
  public ActionResult GetData(long[] allocationId,long batchId)
  {
      var model = context.GetData(batchId)
      model.Name = &quot;asdaksdjaksdj&quot;;
      return View(&quot;Finalize&quot;, model);
  }
  </code></pre>
  <p>I am having some idea, I have to do that on success call back. But I am not sure how to bind my updated model to the view at client side.</p>
  <p>Thanks</p>