Good morning, I have the following code which verifies me through ajax to a file called ultima_cuenta.php that makes a query and returns the last id of a table called accounts, this code is executed once the password is opened. page and it works perfectly, the problem is that if I need it again, it always brings me the same account even though it is not the last one, I read it is cache issues, I search for several parts and tried to put the ajax parameter. cache = false; but it does not work
for it to work I must refresh the explorer with shift + F5 in the case of chromem any idea to prevent that? I must be doing something wrong in the parameter that I put
thank you very much !!
I have the function
function ultima_cuenta(){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var respuesta=this.responseText;
var respuesta_entero = parseInt(respuesta);
$('#label_ultima_cuenta').text(respuesta_entero+1);
}
};
xhttp.open("GET", "../PHP/ultima_cuenta.php", true);
ajax.cache=false; // intenté esto
xhttp.send();
}
ultima_cuenta.php
<?php
require 'conectar.php';
$consulta = "SELECT * FROM cuentas ORDER BY id DESC LIMIT 1" or die('Error. '.mysql_error());
$resultado_consulta = mysqli_query($conexion, $consulta);
$fila = mysqli_fetch_array($resultado_consulta, MYSQLI_ASSOC);
echo $fila["id"];
?>