Having trouble with adding the jQuery plugin select2 to my HTML. I've included select2.min.js in my code.
This is my HTML:
And this is my JS:
$(document).ready(function(){
$.ajax({ url: '/creditdebit/credit/association', type: "GET", success: function(data, textStatus, jqXHR) {
var xdata = $.map(data, function (obj) {
obj.text = obj.text || obj.name;
return obj;
});
$(".association").select2({
placeholder: "test",
data:xdata,
search: data.term,
});
},
error: function (request, textStatus, errorThrown) {
swal("Error ", request.responseJSON.message, "error");
if(request.status == "401"){
alert("Unauthorized Access ");
return false;
}
}
});
});
The issue arises when trying to search for associations. The search feature is not working properly and seems to be malfunctioning in unexpected ways.