Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

266
Views
How to send manual payload in jQuery Datatable?

I was working on jQuery data table without server-side caching and pagination earlier, but now I am getting API that is performing server-side pagination searching and sorting.

I have some idea about server-side functionality provided by data table but my question is how can I pass my own parameters to ajax request, I have noticed that jQuery Datatable sends a payload that contains many things but I need to send some extra information as well to the backend.

My Code-

 $('#dataTable').ready(function () {
    $('#datatable').DataTable( {
    "processing": true,
    "serverSide": true,
    "ajax":{
    "url": "API/GetDetails",
    "dataType": 'json',
    "type": "GET",
    "beforeSend": function(xhr){
     xhr.setRequestHeader("Authorization",
    "Bearer Token");
   }
  }
});

})

Is there any way to change the payload values sent to the backend while making Api request? If yes how and where I should need to edit the code.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can send custom http variables as per their documentation

https://datatables.net/examples/server_side/custom_vars.html

ex:

$(document).ready(function() {
$('#example').DataTable( {
    "processing": true,
    "serverSide": true,
    "ajax": {
        "url": "scripts/server_processing.php",
        "data": function ( d ) {
            d.myKey = "myValue";
            // d.custom = $('#myInput').val();
            // etc
        }
    }
} );

} );

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!