1
I have this script, that when selecting a state, it loads the municipalities that are working, but if I try to save by an action Submit it shows the error. But what the user chose in the municipality disappears, and municipalities are blank.
<script type="text/javascript">
$(function() {
$('#estadoMunicipio')
.change(
function() {
if ($(this).val()) {
$('#municipioEstado').hide();
$('.carregando').show();
$.getJSON('/nota-fiscal-servico-web/buscaMunicipioPorPaisEstado/' + $(this).val(),
function(j) {
var options = '<option value="" class="chosen-select">'
+'</option>';
for (var i = 0; i < j.length; i++) {
options += '<option class="chosen-select" value="' +
j[i].id + '">'
+ j[i].descricao
+ '</option>';
}
$('#municipioEstado')
.html(options)
.show();
$('.carregando').hide();
});
} else {
$('#municipioEstado')
.html(
'<option class="chosen-select" value="">-- Escolha um estado --</option>');
}
});
});
</script>
You can post a simulation to a JSFIDDLE or PLUNKER?
– Jackson
Reload the Page when it shows the right errors?
– Matheus Cuba