I have this method as a dependent call for fetching some data from the back and assiging the return value to "bezeichnung". The AJAX call is executed correctly, however there is no update of the field. The approach works without the AJAX call with some dummy data. Anything missing here?
function cas_nr_to_str(cas_nr) {
$.ajax({
url: `/gefahrenstoffe/${cas_nr}/json`,
type: 'GET',
dataType: 'json',
async: false,
success: function(data) {
var cas_str = data.cas_str;
return {
values: {
bezeichnung: cas_nr + "x"
}
};
},
error: function(error) {
console.error('Error:', error);
}
});
}
editor_create.dependent('cas_nr', cas_nr_to_str);
editor_edit.dependent('cas_nr', cas_nr_to_str);