con questo :
codice:
// Initialize select2 $("#id_id_comuni").select2({
theme: "bootstrap-5",
ajax: {
url: "<?= base_url('AjaxRequest/getComuniSelect')?>",
type: "post",
dataType: 'json',
delay: 250,
data: function (params) {
// CSRF Hash
var csrfName = $('.txt_csrfname').attr('name'); // CSRF Token name
var csrfHash = $('.txt_csrfname').val(); // CSRF hash
return {
searchTerm: params.term, // search term
[csrfName]: csrfHash // CSRF Token
};
},
processResults: function (data) {
return {
results: $.map(data, function (item) {
console.log(item)
return {
text: item.cap+' '+item.localita,
slug: item.slug,
id: item.id
}
})
};
},
cache: true
}
});
ho undefined undefined, il console.log(item) scrivendo roma è allegato