I've got this JSON string
{"plaats":["Rottevalle","Rotterdam"]}
And I like to get "Rottevalle and Rotterdam" as an item in my selectbox with Select2
I've got this code.
$("#plaats").select2({
minimumInputLength: 3,
tags: [],
ajax: {
url: 'plaatsen.php',
dataType: 'json',
delay: 250,
data: function (params) {
return {
q: params.term, // search term
page: params.page
};
},
processResults: function (data) {
return {
results: $.map(data, function(obj) {
return { id: obj.plaats, text: obj.plaats };
})
};
}
}
});
Problem is that I don't understand how I get the plaats data back within processResults.