loading datatables but it is not sending extra parameter ti the page
loading datatables but it is not sending extra parameter ti the page
maniya
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,
This discussion has been closed.
Replies
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
my case is not considered here, if i run the above code by copy pasting what is sitetable
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
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.