hello i need help please , I’m new to select2 i want to use it to search ,I can see the ajax call working in network but the only problem it not appear in list
a simple json response
i want title and id from it
items: [
{
id: 293,
title: "Solo max",
author: "Updating",
},
{
id: 294,
title: "Solo imo",
author: "Updating",
},
{id: 295,
title: "Solo pain",
author: "Updating",}]}
<div class="form-group">
<div class="row">
<label class="col-md-2">duplicatejjjd : </label>
<div class="col-md-8">
<select class="js-data-example-ajax form-control"></select>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script>
<script type="text/javascript" class="js-code-placeholder">
$('.js-data-example-ajax').select2({
ajax: {
url: function (params) {
return 'ajax link/';
},
dataType: 'json',
data: function (params) {
var query = {
search: params.term
}
return query;
},placeholder: 'Search ',
minimumInputLength: 1
}});
</script>