cancel
Showing results for 
Search instead for 
Did you mean: 

How to populate admin uiComponent from Ajax

How to populate admin uiComponent from Ajax

I would like to populate an admin uiComponent from Ajax. At the moment it returns data 'array', but it does not populate the select with it.
define([
    'jquery',
    'underscore',
    'uiRegistry',
    'Magento_Ui/js/form/element/select',
    'Magento_Ui/js/modal/modal',
    'mage/url'
], function ($, _, uiRegistry, select, modal, url) {
    'use strict';

    return select.extend({

        onUpdate: function (value) {
            console.log('Selected Value: ' + value);

       ;
          
             var linkUrl = url.build('customajax');
            



                    $.ajax({
                        url: linkUrl ,
                        showLoader: true,
                        data: {form_key: window.FORM_KEY, 'value':value},
                        type: "POST",
                          dataType : 'json',
                        success: function(data){
                        

                           console.log(data.array);
            uiRegistry.get('index = attribute_value_id').options(myArray);
                        }
                    });


         return this._super();
        },
    });
});