Getting error "$(..).Datatable is not a function"

When I am trying to add jQuery datatable in my ASP.NET Core project I am getting below error "$(..).DataTable is not a function", here is the error image in Google Chrome console.


Although I have added jQuery datatable reference in my code.

<link href="" rel="stylesheet" type="text/css" />
<div style="width: 500px">
    <table id="tblEmp" cellpadding="0" cellspacing="0" border="1" style="border-collapse:collapse">
                <th>First Name</th>
                <th>Last Name</th>
    <script type="text/javascript" src=""></script>

    <script type="text/javascript">
        $(document).ready(function () {
                "processing": true, 
                "serverSide": true, // enabling server side
                "filter": true, //set true for enabling searching
                "ajax": { 
                    "url": "/home/person",// ajax url to load content
                    "type": "POST", // type of method to call
                    "datatype": "json" // return datatype
                "columns": [
                    { "data": "firstName", "name": "First Name", "autoWidth": true }, // columns name and related settings
                    { "data": "lastName", "name": "Last Name", "autoWidth": true },


Asked by:- bhanu
: 3388 At:- 3/31/2022 12:43:44 PM
Javascript jQuery datatable is not function

1 Answers
profileImage Answered by:- vikas_jk

This error can be due to any one of the following causes:

  • jQuery Multiple versions included
  • jQuery library loaded multiple times.
  • jQuery datatable library is added before jQuery library
    <script type="text/javascript" src="~/Scripts/jquery.js"></script>
    <script type="text/javascript" src="~/Scripts/data-table/jquery.dataTables.js"></script>
     <script>$(document).ready(function () {
        var table = $('#MyTable').DataTable();
  • jQuery DataTables library script reference is missing.

In your .NET project, I will suggest you to wrap all Javascript code as inside "Scripts" section, if you are loading JS/CSS bundles, so if you are loading JS files on the master page (_Layout.cshtml) in .NET MVC project, it works fine.

@section Scripts{
    <script type="text/javascript" src=""></script>
 // JS code here

also, load jQuery datatable, after jQuery library, something like this

<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/jquery.dataTables.min.js" type="text/javascript"></script>

to get rid of error.

At:- 3/31/2022 12:53:45 PM Updated at:- 12/15/2022 1:52:44 AM
ok, I see, I was loading jQuery library multiple times in _Layout.cshtml. 0
By : bhanu - at :- 3/31/2022 12:56:16 PM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use