VM127:2 Uncaught TypeError: $(...).dataTable is not a function at getauctionitems (:3

VM127:2 Uncaught TypeError: $(...).dataTable is not a function at getauctionitems (:3

JohnmaikaboJohnmaikabo Posts: 1Questions: 1Answers: 0

this is my code,when i click at first,the table loads without a problem but when i click on another page and click again to load the dataTable,i get an error..VM127:2 Uncaught TypeError: $(...).dataTable is not a function at getauctionitems (<anonymous>:3

Auction Number Auction Time Sale Name Region Sale Type Auction Date Status Auction Name

$(document).ready(function(){

getauctionitems();

function getauctionitems () {

    var date = new Date();
    var dateString = new Date(date.getTime() - (date.getTimezoneOffset() * 60000 )).toISOString().split("T")[0];



     var today = new Date();

     var todays = today.toLocaleTimeString();

     var h = today.getHours();
     var m = today.getMinutes();

     h = checkTime(h);
     m = checkTime(m);


    var ctime = h + ":" + m;

///    console.log(ctime);


    function checkTime(i) {

       return (i < 10) ? "0" + i : i;
    }



 $('#listtables').dataTable({

            "processing": true,
            "responsive": true,
            "serverSide": false,
            "retrieve": true,
            "destroy": true,
            "ajax": {
                url: "serverside/list.php", // json datasource
                "data": {
                    "cdate": dateString,
                    "curtime":ctime
                 },
                type: 'post',  // method  , by default get
            },



           "columns": [


            {data:null,
                render: function ( data, type, row ) {
                  return '<input type="checkbox" >';
               }

            },


             {data: 'auctionid',
               'createdCell':  function (td, cellData, rowData, row, col) {
               $(td).attr('id', 'auctionidd');
         //    $(td).css('display','none');

              } 

            },

             {data: 'time',
               'createdCell':  function (td, cellData, rowData, row, col) {
               $(td).attr('id', 'scheduletimeid');
           ///   $(td).css('display','none');

              } 

            },

            {data: 'locationn',
               'createdCell':  function (td, cellData, rowData, row, col) {
               $(td).attr('id', 'locationnid'); 
              } 

            },

            {data: 'regionn',
                  'createdCell':  function (td, cellData, rowData, row, col) {
                   $(td).attr('id', 'scheduleregionid'); 
             } 

             },

            {data: 'comp',
                'createdCell':  function (td, cellData, rowData, row, col) {
                    $(td).attr('id', 'companyid'); 
            } 

            },


            {data: 'auctionndate',
                'createdCell':  function (td, cellData, rowData, row, col) {
                 $(td).attr('id', 'currentdateid'); 
                 $(td).css('cursor', 'pointer');
              }

            }    
            ,

            {data: 'date',
                'createdCell':  function (td, cellData, rowData, row, col) {
                 $(td).attr('id', 'statusid'); 
                 $(td).css('cursor', 'pointer');
              }

            }    
            , 


             {data: 'name',
                'createdCell':  function (td, cellData, rowData, row, col) {
                    $(td).attr('id', 'nameid'); 
            } 

            },


       ]
    });  

}

});

Answers

  • colincolin Posts: 12,441Questions: 0Answers: 2,107

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

Sign In or Register to comment.