I am trying to implement Remote Data Select2.
I am accessing data from api. The format is as follows:
concept_id,name
228,Pelecypoda
286,Pelecypoda
When I try to console data in results, it doesn't get consoled. But if I replace the word results with success, I can see the data in console but not in the search results.
Script
$("#search_text").select2({
minimumInputLength: 3,
ajax: {
url: "http://192.241.245.176:4567/api1",
dataType: 'text',
type: "GET",
quietMillis: 250,
data: function (term) {
console.log(term)
return {
q: term.term //search term
}
},
results: function (data,page) {
console.log(data,"-----RESULTS-----");
return d3.csv.parse(data, function (d) {
console.log(d);
return {results: d.name}
});
},
dropdownCssClass: "bigdrop"
});
Can anyone please tell me where am I going wrong? Do I have to specify formatResults and formatSelection provided by select2?