1
I’m trying to fill a dropdown menu that when Torina is placed on a button this works.
But since I want this fill-in to happen automatically as soon as the document is loaded into jQuery.ready() for this, however, the function invoked in it does not work, that is, the menu is not being filled.
Current code:
function PreencheCombo() {
var str = "";
$.ajax({
url: '/Cadastro/PreencheComboUf',
datatype: 'json',
contentType: "application/json; charset=utf-8",
type: "POST",
success: function (data) {
str += '<label for="cbxUf" class="col-sm-4 control-label">UF</label>';
str += '<select class="form-control col-sm-4" name="cbxUf" id="cbxUf">';
$(data.result_combo).each(function () {
str += '<option value=' + this.sigla + '>' + this.descricao + '</option>';
})
str += '</select>';
$('#combo').html(str);
},
error: function (error) {
}
})
}
And the invocation:
$(document).ready(function () {
PreencheCombo();
});
If I put a button to call the function Filler then it works, so it is the ready that is not working.
It’s not clear what you’re asking... gift??
– CesarMiguel
I made an edit and switched to document
– pnet