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

328
Visualizações
Using js load to reload content of multiple tables but with transfered php variables/arrays

So first of all let me explain how my php/js setup looks like:

enter image description here

enter image description here

So now when you have an idea of how it looks, I have a question about how to do my load, to reload my table without reloading my page.

I know how to do it the simple way like this:

PHP (getTable.php) - this can be any server side code (asp, html, etc..)

<?php
    echo '<table><tr><td>TEST</td></tr></table>';
?>

Then, in your JS, you can easily refresh the table by using the load() method:

HTML

<div id="tableHolder"></div>

JS

<script type="text/javascript">
    $(document).ready(function(){
      refreshTable();
    });

    /*Call this when table should be updated*/
    function refreshTable(){
        $('#tableHolder').load('getTable.php');
    }
</script>

But how can I use the $('#tableHolder').load('getTable.php'); and transfer the variables needed to getTable.php string/arrays?. Because I need to run a loop in this file running sql queries, instead of in my dashboard.php/functions.php file. Because then I could just update my tables after something has been changed with load.

what I need to do:

//Create all the divs needed (the ones to be updated)
foreach($arrayThings as $projects){
    echo'<div id="'.$projects.'"></div>';
}

//JS script that should be triggered when divs has to be updated
/*Call this when table should be updated
* But how can I transfer data to this php file and load it? cant create the table without doing 
* some calculations and sql calls to create these tables.
*/
function refreshTable(id){
    $('#'+id).load('getTable.php');
}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use second parameter in load() to send array. That should send as POST.

$('#'+id).load('getTable.php', { "param1" : "value1" });

https://api.jquery.com/load/

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