loading datatables but it is not sending extra parameter ti the page

loading datatables but it is not sending extra parameter ti the page

maniyamaniya Posts: 78Questions: 13Answers: 0

Trying to pass the url value to ajax call datatables but it is not sending the key and its value

if (!$.fn.DataTable.isDataTable ('#errorslistDetails')) {
        $('#errorslistDetails').DataTable({
            "processing": true,
            "serverSide": true,
            "stateSave": true,
            "ajax": {
                "url" : "data.cfm",
                "data": function(d){
                    d.urlerrorid = $(this).attr('data-errorid')
                }
            },
            "columns": [
                { "data": "status" },
                { "data": "errorid" },
                { "data": "id" }
            ]
        });
    }

Following datatables, but not sure what is going wrong, i think its because datatable is getting loaded and it does not find the attribute, but its not even sending the key

so not sure what i am doing error, no error happening in console

if i pass a hardcoded value without a callback in the data, it works,

Replies

  • rf1234rf1234 Posts: 2,949Questions: 87Answers: 416

    Hard to tell from your code ... Just take a look at this please. You might need to use type: post to have the variable as a post variable on the server?!

    Just like in this blog:
    https://datatables.net/blog/2016-03-25

  • maniyamaniya Posts: 78Questions: 13Answers: 0

    my case is not considered here, if i run the above code by copy pasting what is sitetable

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    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

  • rf1234rf1234 Posts: 2,949Questions: 87Answers: 416
    edited August 2020

    my case is not considered here, if i run the above code by copy pasting what is sitetable

    Well I didn't say you should copy and paste that stuff. It was only to highlight how to send variables to the server to be used as $_POST global variables in PHP.

    So if you want to send "urlerrorid" to the server and want to use it as a $_POST global variable in PHP you would need to specify type:'post' - which you didn't in your code.

    That's all.

This discussion has been closed.