Hi mahesh213,
Check this example. Now please take its reference and correct your code.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
Controller
public class HomeController : Controller
{
// GET: /Home/
public ActionResult Index()
{
return View();
}
public int CheckCount()
{
NorthwindEntities entities = new NorthwindEntities();
int i = entities.Employees.Count();
return i;
}
}
View
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$.ajax({
type: "POST",
url: "/Home/CheckCount/",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
if (r > 0) {
$('[id*=content]').html("");
} else {
$('[id*=content]').html("No records found");
}
}
});
});
</script>
<div id="content">
</div>