0
Good afternoon. I use a JSON response search for a UF and City field. To recover cities by UF with JSON, I use this code in JS.
$('select[id=uf]').change(function () { // ativa a função quando é selecionado uma UF pelo id = uf
var uf = $(this).val(); // recebe o valor da UF
$.get('/get-cidades', {uf : uf}, function (busca) { // pesquisa pela url com a rota /get-cidades/uf-selecionada
$('select[name=cidades]').empty(); // procura o campo com o name = cidades
$.each(busca, function (key, value) {
$('select[name=cidades]').append('<option value=' + value.id + '>' + value.name + '</option>'); // add os option
});
});});
So far so good, everything works correctly. The select that receives the found cities is multselection, so to not leave the field in the original HTML style, I use a jquery extension.
$('#cidades').multiselect({
numberDisplayed: 0,
includeSelectAllOption: true, });
The problem is that when I add this extension of jquery, I no longer get the values in the cities field, the field is left with no option. I will place 2 images demonstrating what happens.
With jquery.
Uncaught Typeerror: $(...). appendchild is not a Function. This is happening in the log
– Luiz Gustavo Costa Ceolin
what the documentation page of this extension is using?
– andrepaulo
https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js
– Luiz Gustavo Costa Ceolin
There’s one more script tbm, but I don’t have the way.
– Luiz Gustavo Costa Ceolin
In case that’s the main thing about your problem...
– andrepaulo