Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

263
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda