Skip to content

Instantly share code, notes, and snippets.

@paulopatto
Forked from macedo/gist:4394072
Created January 17, 2014 17:37
Show Gist options
  • Save paulopatto/8477767 to your computer and use it in GitHub Desktop.
Save paulopatto/8477767 to your computer and use it in GitHub Desktop.
$('.cep').blur(function() {
var cep = $(this).attr('value').replace(/-/, '');
$.ajax({
url : 'http://cep.correiocontrol.com.br/' + cep + '.json',
dataType: 'json',
success: function(data) {
console.log(data);
$('#address').attr('value', data.logradouro);
$('#neighborhood').attr('value', data.bairro);
$('#city').attr('value', data.localidade);
$('#state').attr('value', data.uf);
},
error: function(data) {}
});
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment