Currently, I am in the process of setting up tagging and utilizing ajax to display the most commonly used tags. To accomplish this, I decided to employ the Select2 plugin. However, I encountered a roadblock when attempting to retrieve my JSON Data in my javascript code. Here is where I stand thus far:
$("#tags").select2({
ajax: {
url: "api/v1/tags/",
dataType: "json",
cache: true,
quietMillis: 150,
allowClear: true,
data: function(params) {
return {
tags: params.term
}
},
processResults: function (data) {
return {
results: $.map(data, function(obj) {
return {
id: obj.id,
text: obj.slug
};
})
};
}
},
tags: true,
placeholder: "Search or insert tags",
tokenSeparators: [',', ' '],
});
Unfortunately, I am encountering the following error message:
GET 404 (Not Found)
The JSON Data I have saved is located in these directories: /api/v1/tags/a
... /api/v1/tags/z
I am curious about how to modify the url parameters ?tags=keyword
in the Select2 Parameters to /keyword
. I have searched through the vendor documentation, but have not found a solution. Can someone provide guidance on this matter? Your assistance would be greatly appreciated.