Could you please help me cause I'm stuck :/ I have a snippet where I want to add data from API to my selectize field. I prepared this selectize field manually in the system cause I have to. Here I just want to pass this data. Here is my snippet:
function getCarriersData() {
const queryType = "GET";
const funcName = "getcarriersdata";
const queryUrl = globalDataObject.appRootPath + "api/extension/" + funcName;
$.ajax({
url: queryUrl,
type: queryType,
success: function(result) {
const przewoznik = $('span[data-inputattrname="KZ_Kurier_DP_przewoznik"]').find('select')[0].selectize;
if (Object.keys(przewoznik.options).length == 0) {
console.log('That part works')
$.each(JSON.parse(result), function(i, item) {
przewoznik.addOption({ value: item.Name, text: item.Name });
przewoznik.setValue(item.Name, false)
});
}
}
});
} I receive data from API and I parse it to multiple objects (JSON.parse), but still doesn't work.