Click here to Skip to main content
15,745,005 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
<pre lang="c#"><pre>[HttpPost]
        public ActionResult CheckEmployee(Chart obj)

            SqlConnection con = new SqlConnection(@"Data Source=MAHGOUBND4;Initial Catalog=CTC_Mahgoub;Persist Security Info=True;User ID=sa;Password=8008989;");
            SqlCommand cmd = new SqlCommand("SELECT * FROM cs INNER JOIN( select EmployeeName FROM cs GROUP BY EmployeeName  HAVING Count(*) > 1) " +
                " As DuplicateRows ON DuplicateRows.EmployeeName = cs.EmployeeName)",con);
            cmd.Parameters.AddWithValue("@EmployeeName", obj.EmployeeName);
            cmd.Parameters.AddWithValue("@DuplicateRows", obj.DuplicateRows);

            return Json( JsonRequestBehavior.AllowGet);

and yhis is my view code
<pre> @model Asp.NETMVCCRUD.Models.Chart
    ViewBag.Title = "CTC";
<table id="employeeTable" class="table table-striped table-bordered" style="width:100%">
            <th>Employee Name</th>
<link href="//" rel="stylesheet" />
<link href="" rel="stylesheet" />
<link href="" rel="stylesheet" />
<link href="" rel="stylesheet" />
@section scripts{
<script src="//"></script>
<script src=""></script>
<script src=""></script>

<script type="text/javascript">
    var Popup, dataTable;
    $(document).ready(function () {

        dataTable = $("#employeeTable").DataTable({

            "ajax": {
                "url": "/chart/CheckEmployee",
                "type": "GET",
                "datatype": "json"
            "columns": [

                { "data": "EmployeeName", "name": "EmployeeName", "autoWidth": true },
                { "data": "DuplicateRows", "name": "DuplicateRows", "autoWidth": true },

            "orderable": false,
            "searchable": false,
            "width": "150px",
            "dom": "Bfrtip",
            "language": {

                "emptyTable": "No data found, Please click on Add New Button"


What I have tried:

and i show this Error
DataTables warning: table id=employeeTable - Ajax error. For more information about this error, please see
Updated 7-Aug-20 0:56am
Sandeep Mewara 7-Aug-20 6:52am    
DataTables warning: table id=employeeTable - Ajax error
Is that the total error and exact one?
silantmagicbbb 7-Aug-20 7:06am    
can you update my code iam try alot of way but all of thim failed

1 solution

public ActionResult CheckEmployee(Chart obj)
"ajax": {
    "url": "/chart/CheckEmployee",
    "type": "GET",
    "datatype": "json"
Your action requires a POST request, and requires a Chart object as its parameter.

Your Javascript is making a GET request, and is not passing any parameters.

Check the developer console in your browser, and you'll see that the request to /chart/CheckEmployee is returning a 404 error.

You'll also need to correct your action to return the appropriate data to be consumed by the plugin.
Share this answer
silantmagicbbb 7-Aug-20 7:13am    
Can you explain with an example of my code
Richard Deeming 7-Aug-20 7:24am    
No, because your code is incomplete.

Have a look at this series of articles for some ideas:
jQuery DataTables and ASP.NET MVC Integration - Part I[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900