Can anyone tell me why this pics of code is not refreshing the view in every 1 sec
<div id="AutoRefresh">
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Employees.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.RequestTypes.RequestTypeName)
</th>
<th>
@Html.DisplayNameFor(model => model.Comments)
</th>
<th>
@Html.DisplayNameFor(model => model.Inserted_Date)
</th>
<th>Action</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Employees.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.RequestTypes.RequestTypeName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Comments)
</td>
<td>
@Html.DisplayFor(modelItem => item.Inserted_Date)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
</tr>
}
</table>
@section Scripts {
<script type="text/javascript">
$(function () {
setInterval(function () { $('#AutoRefresh').load('/RequestApprovals/Index'); }, 1000); // every 1 sec
});
</script>
}
Controller Action Method:
// GET: RequestApprovals
public async Task<ActionResult> Index()
{
var requestApprovals = db.RequestApprovals.Include(r => r.Employees).Include(r => r.RequestTypes);
return View(await requestApprovals.ToListAsync());
}
I have a _Layout.cshtml file in my shared folder if i use meta tag inside layout page it refresh all the view that use that _Layout.cshtml but i want only one view that contains above code should refresh. I tried above code but it is not working for me. please suggest me what i should do ?