I'm already trying to populate a select ajax options, among the various options I found the plugin selec2 and I'm trying like this:
$(function () {
$(".disciplina").select2({
language: "pt-BR",
placeholder: "Disciplina",
allowClear: true,
minimumInputLength: 0,
ajax:{
url: "busca.asp",
type: "post",
dataType: "json",
delay: 150,
data: function(params){
return{
text: params.term
};
},
processResults: function(data, params){
params.page = params.page || 1;
return{
results: data,
pagination:{
more: (params.page * 30) < data.total_count
}
};
},
cache: true
}
});
});
<form action="" method="post">
<select class="disciplina"></select>
</form>
But I had a question, what kind of data should I return in the url: base_url ("search.asp")?
As you can see use asp3 in this project and there is no solution to bring an array in json format as in Php, so I got a kick.
set rs = Conn.Execute ("SELECT discipline_id, discipline FROM discipline ORDER BY ASC discipline;") while not rs.EOF response.write ("{" "discipline_id" ":" "" & rs ("discipline_id") & "", "" discipline "": "},") rs.MoveNext wend rs.Close set rs = Nothing
Help me, I'm going crazy already.