Problem with JSON object [closed]

1

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);
            }   
        }
    });
});
    
asked by Wailo CARP 23.08.2017 в 20:46
source

1 answer

-2

This would be the form that contains the input to rellnear and the submit with id="search_company".

<div style="width:100%; text-align:center;">
<form  name="form1" action="registro.php" method="POST">
<table align="center">
    <tr>
        <td><input type="text" name="razon" id="razon" size="32" placeholder="Razon social"/></td>
        <td><input type="submit" name= "buscar_empresa" id="buscar_empresa" value="Buscar"/></td>
    </tr>
    <tr>
        <td><input type="text" name="cuit" id="cuit" size="32" placeholder="CUIT"/></td>
    </tr>
    <tr>
        <td><input type="text" name="tel_empresa" id="tel_empresa" size="32" placeholder="telefono/celular"/></td>
    </tr>
        <tr>
        <td><input type="text" name="codigo" id="codigo" size="32" placeholder="codigo"/></td>
    </tr>
</table>
    <input style="float:left; margin-left:50px;" type="submit" name="continuar" value="Continuar sin registro"/>
    <input style="float:right; margin-right:50px;" type="submit" name="registrar" value="Registrar"/>
</form>
</div>
    
answered by 24.08.2017 в 13:45