0
I’m having a problem with a college project.
I would like to know how to run this Ajax script automatically:
<script type="text/javascript">
function buscaCep() {
var cep = $( "#cep" ).val();
var infos = {
'iCep': cep
};
$.ajax( {
crossDomain: true,
type: "POST",
url: "",
data: infos
} ).done( function ( data ) {
var json = $.parseJSON( data );
$( "#log" ).val( json.lograd );
$( "#cidade" ).val( json.cidade );
$( "#bairro" ).val( json.bairro );
$( "#estado" ).val( json.estado );
} );
}
After the user fills in an input:
<input type="text" name="cep" id="cep" onkeyup="maskIt(this,event,'#####-###')"/>
Thanks for the code helped a lot!
– Vinnicius Gomes