I have a problem with the JSON object (jQuery using the $.post
method) where I try to search my database (mysql) with an input and fill in the rest after consultation. The point is that I fill in these fields for a few seconds, with the corresponding data but they are automatically cleaned.
Here I leave the function
$(document).ready(function()
{
$("#buscar_empresa").click(function()
{
var postsend=$.post("buscar.php",{"cuit":$("#cuit").val()},"json");
postsend.done(function(data))
{
if(data.razon=="")
{
$("#cuit").val("");
}
else
{
$("#razon").val(data.razon);
$("#cuit").val(data.cuit);
$("#tel_empresa").val(data.telefono);
$("#codigo").val(data.codigo);
}
}
});
});