Trying to make ajax call but not working with version 1.10.16

Trying to make ajax call but not working with version 1.10.16

testmb0407testmb0407 Posts: 3Questions: 1Answers: 0

I m using datatable version 1.10.16 and trying to use ajax call but its not working.
I have a datatable which showing data (only last 7 days because I have huge amount of data) while page upload (Working Perfect). Now I add a custom date range option for search my data date wise, so when I m trying to make a ajax call its giving me error that parentnode can not be null.

Please help.

Answers

  • testmb0407testmb0407 Posts: 3Questions: 1Answers: 0

    it's exact error
    "jquery.dataTables.min.js:137 Uncaught TypeError: Cannot read property 'parentNode' of null"

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    Hi @testmb0407 ,

    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

  • testmb0407testmb0407 Posts: 3Questions: 1Answers: 0
    edited April 2019

    Hi @colin ,

    Thanks for your response.
    I have forgot to attached the code. Now I have attached the code, please have a look and suggest.

    Now I m getting "DataTables warning: table id=example - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3" error.

    $(document).ready(function() {
            var start_date = '02-04-2019';
            var end_date = '30-03-2019';
            var click_by_apply = 2;
            //var get_date_range = $('#reportrange span').html();
            //console.log(get_date_range);
            datatableFunction(start_date,end_date,click_by_apply);
            $('#applyDate').click(function(){
                var start_date = '02-04-2019';
                var end_date = '30-03-2019';
                var click_by_apply = 1;
                datatableFunction(start_date,end_date,click_by_apply);
            });
        } );
        function datatableFunction(start_date,end_date,click_by_apply){
            $('#example').DataTable({
                "ajax": {
                    "url": "ajax.php",
                    "data": {
                        "start_date": start_date,
                        "end_date":end_date,
                        "click_by_apply":click_by_apply
                    }
                 },
                //"ajax": "ajax.php",
                "columns": [
                    { "data": "lead_id" },
                    { "data": "full_name" },
                    { "data": "first_name" },
                    { "data": "last_name" },
                    /*{ "data": "extn" },*/
                    { "data": "created_at" },
                    // { "data": "salary" }
                ]
            });
        }
    
  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    The link provided in the error message explains how to resolve the problem.
    In your case, you are initialising DT inside a function which is called more than once.

    Otherwise, please provide a link to a test case as already requested by Colin.

This discussion has been closed.