I am trying to populate my multiple select2 with ajax, but I have no return in the field.
What is my HTML code:
<input type="hidden" id="instituicaoSel" tabindex="-1" class="select2-offscreen" value="">
JavaScript:
$('#instituicaoSel').select2(
{
placeholder: "Escolha uma ou mais instituições",
minimumInputLength: 1,
width: '100%',
multiple: true,
ajax: {
url: basepath + "perfil/buscarInstituicoes",
dataType: 'json',
quietMillis: 100,
data: function (term, page) {
return {
q: term,
page_limit: 10,
page: page
};
},
results: function (data, page)
{
var more = (page * 10) < data.total;
return { results: data.results, more: more };
},
dropdownCssClass: "bigdrop"
}
});
And this is my ajax result:
[{"result":[{"id":"1","text":"Ag\u00eancia Brasileira de Desenvolvimento Industrial"}],"total":1}]
The value that I put in the placeholder is not displayed.
source
share