Hello, I need to fill a select field with the return of this function, in this example, the variable RES returns:
<option value="">setor 1</option>
Just this, I need it to become one of the options in my select field, but nothing happens, I'm trying like this:
$('#cSetor').html(res);
where cSetor is the ID of my select field
JavaScript:
$(document).ready(function() {
$('#cSecretaria').on('change', function() {
$.post('_require/_jp/jpcarregasetor.php', {
id_sec: document.getElementById("cSecretaria").value,
}, function(res) {
$('#cSetor').html(res);
})
})
})
HTML:
<div class="form-group col-md-4">
<label for="cSetor">Setor pertencente</label>
<select class="form-control selectpicker" title="--" name="tSetor" id="cSetor">
</select>
</div>