0
Whenever I use Ajax to return a database result it stores this result by making a sort of queue in the next requests, returning in other queries old data next to the current ones, example...
$inputgetCod = (isset($_POST['codBarras'])) ? $_POST['codBarras'] : '';
...
else{
$sql = 'SELECT nome,valorUnt from produtos where codigoBarras = ?';
$stm = $conexao->prepare($sql);
$stm->bindValue(1, $inputgetCod);
$stm->execute();
$dads = $stm->fetch(PDO::FETCH_OBJ);
$vlt = $dads->valorUnt;
$nm = $dads->nome;
$retorno = array('codigo' => 0, 'mensagem' => 'cadastrado com sucesso', 'acerto' => $acerto, 'nome' => $nm, 'vlt' => $vlt);
echo json_encode($retorno);
exit();
}
Ajax
var ajaxID = 0;
$.ajax({
type : 'POST',
url : '../phpVld/validaGetprod.php',
data : data,
dataType: 'json',
cache : false,
success : function(response){
$(".algumCampo").append(response.algum_dado);
}
when I call this request again via a button it returns the old data together with the current ones, there is some way to return only data from one request at a time?
managed to solve the problem?
– Denis Rudnei de Souza
I got yes man, it was wrong n vote, on the date of the question I did not know much on the site
– Felipe Duarte
Normal, even today there is something I doubt
– Denis Rudnei de Souza