0
Hello,
On my system I intend that, the user select the data present within the dropdowns and click confirm, the selected value goes to the document filtraDashboardGeral.php, with a PHP function SELECT in my table, returns the result using the method value POST as a parameter and the return of this function is inserted in the variables I already have on my main page, it is 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
Briefly, I want to change the value of my session variables through an Ajax request, which are session variables, it is possible?
Grateful.
Yes it is possible, it gives some error?
– Miguel
@Miguel, actually, I don’t know how to return the values I picked up in the filter into my variables
– João Vitor
John but no mistake, right? Just want to return
$dados['rede']back to customer side? PS: this line:$_SESSION['redeAtual'] = $dados['rede'];, is not making sense, is rewriting the value of the variable$_SESSION['rede']every loop– Miguel
@Miguel, error 500. (I edited my script to try to display something but nothing, I changed in the post). This was the only way the head came to set the variable with the array value
– João Vitor
@Miguel follows http://imgur.com/VXwOjJD error
– João Vitor
That’s not the error I want to see, it’s the server-side error, d3eves has an error in php. You need to see this tab: https://postimg.org/image/3s3fa533b/ . Network->all->Sponse , and click on
filtraDashboardGeral.phpon the left side– Miguel
@Miguel segue https://postimg.org/image/k1o1elv45/ php n returns no error
– João Vitor
John on the left side, in the list of requests that are made to be there (when you make the request ajax) the file
filtraDashboardGeral.php, click on it when it appears and onresponse– Miguel
https://postimg.org/image/wgl5j4km7/ now appeared
– João Vitor
Ok, well now click on the Response tab instead of "headers". Hopefully you have php errors enabled
– Miguel
@Miguel without any error in the Answer tab, says that no data is available
– João Vitor
Ok, so now put it on the server side (php)
echo 'olá';after the foreach, do it again and see the– Miguel
Failed to load Response data
– João Vitor
This appeared where? in Sponse?
– Miguel
@Miguel was yes.
– João Vitor
You don’t need to put the php file function in your request?
'datacenter/functions/filtraDashboardGeral.php/funcao'– Hozeis