PHP + Ajax Data Return

0

Hello,

In my system I want the user to select the data present inside the dropdowns and click confirm, the value selected goes to the document filtraDashboardGeral.php , with a PHP function does SELECT in my table, returns the result using the value of the POST method as a parameter and the return of that function is inserted into the variables I already have on my main page, is it possible?

My script:

$("#botao-filtrar").click(function(){
    $(".mask-loading").fadeToggle(1000);
    $.ajax({
        url: 'datacenter/functions/filtraDashboardGeral.php',
        type: 'POST',
        data: {rede: $("#dropdown-parceria").val()},
    })
    .done(function(resposta){
        console.log(resposta);
    })
    .always(function(){
        $(".mask-loading").fadeToggle(1000);
    })
});

My document filtraDashboardGeral.php :

<?php
    $rede = $_POST['rede'];

    function buscaDados($conexao){
        $dados = array();

        $resultado = mysqli_query($conexao, "SELECT * FROM evolucao_originacao WHERE rede = {$rede}");

        while($valores = mysqli_fetch_assoc($resultado)){
            array_push($dados, $valores);
        }
    }

foreach ($dados as $filtrados) :
    $_SESSION['redeAtual'] = $dados['rede'];
endforeach
  

In short, I want to change the value of my session variables through an Ajax request, which are session variables, is it possible?

Thank you.

    
asked by anonymous 06.12.2016 / 17:52

0 answers