I have several JS files that validate fields, it happens that when the condition is fulfilled they make the alert and then it is again fulfilled and it continues that way until you mark "Avoid this page ..."
How do I solve it?
Example get called with ONBLUR
function obtener() {
var ejemplo= { xvalor: $('#valor').val() }
$.post("unarchivo.php", xvalor , function( respuesta ) {
if(respuesta.a==99999 )
{
alert("No existe");
$('#ejemplo').val("");
}
else
{
$('#a').val(respuesta.a);
$('#b').val(respuesta.b);
$('#c').val(respuesta.c)
}
}, "json" );
I thought that one of the problems was to do the FOCUS to the value and remove it but it persists.
Or maybe that by entering the value wrong and leaving (blur) it puts the empty box and as empty does not exist in the database it gives you an error and makes a loop?
What can I do to only show the value and not persist
HTML:
<script src="funciones/obtener.js"></script>
<tr>
<td>Cedula: </td>
<td colspan="3">
<input type="text" name="ccedula" id="ccedula" onblur="obtenerSancionado()" maxlength="10" size="12"></td>
</td>
</tr>
PHP:
the php if it does not get the value, it happens in response that a = 9999 That's why then the first condition is fulfilled
if ($stmt->num_rows === 0)
{
$datos = json_encode(array(
"a" => '99999'
));
echo $datos;
}