title: Reload index view after deleting a record on it on ajax call
body: <p>I have list of items on index view &amp; a delete button corresponding to each item. I want to delete a record with confirmation from end user. Record is getting deleted with confirmation from db but still exists on UI. So I created a shared view named "IndexReloader". which is returned after deleting &amp; in this view I am reloading the index view. Here's my code      </p>
  
  <pre><code>    [HttpPost]
      public ActionResult Delete(int? Id)
      {
          SqlConnection ObjSqlCon = null;
          try
          {
              var SqlQuery = @"DELETE FROM [USER] WHERE USERID = " + Id;
  
              var ConnectionStr = ConfigurationManager.ConnectionStrings["MVCConnectionString"];
              // create a connection object
              ObjSqlCon = new SqlConnection(ConnectionStr.ToString());
  
              // create a command object
              var ObjSqlCmd = new SqlCommand(SqlQuery, ObjSqlCon);
              // open the connection
              ObjSqlCon.Open();
  
              ObjSqlCmd.ExecuteNonQuery();
              //return View("IndexReloader");
              return View("~/Views/Shared/IndexReloader.cshtml");
          }
          catch (Exception Ex)
          {
              return View();
          }
          finally
          {
              if (ObjSqlCon != null)
              {
                  ObjSqlCon.Close(); ObjSqlCon.Dispose();
              }
          }
      } 
  </code></pre>
  
  <p>The IndexReloader view,</p>
  
  <pre><code>@{
      Layout = "~/Views/Shared/_Layout.cshtml";
  }
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;IndexReloader&lt;/title&gt;
      &lt;script type="text/javascript"&gt;
  
          $(document).ready(function () {
              //location.reload();
              alert("hey");
              window.location.replace("http://localhost/LearningMVC/My/Index.cshtml");
          });
  
  &lt;/script&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>In master page I have included jquery script files. I want my index view to be loaded with latest data as soon as I delete a record. How can I achieve this?</p>