I need to make "selected='selected'"
in option
whose value is what is written to the state variable retrieved in Ajax. How can I do this?
$('#cep').on("change", function(){
$.ajax({
url: 'http://cep.republicavirtual.com.br/web_cep.php',
type: 'get',
dataType: 'json',
crossDomain: true,
data:{
cep: $('#cep').val(),
formato:'json'
},
success: function(res){
res.uf; = "24";
estado = res.uf;
...
// Estados dentro do select ...
<select name="estado" id="estado" class="form-control mb-md">
<option value="">Selecione um estado ...</option>
<option value="1">Acre</option>
<option value="2">Alagoas</option>
<option value="3">Amazonas</option>
<option value="4">Amapá</option>
...