I have this piece of JS:
  $.ajax({
    url: '/my-url',
    dataType: 'json',
    success: function(json) {
      for (var i = 0, ien = json.data.length; i < ien; i++) {
        createPanel(json.data[i]);
        var options = json.options;
        console.log(options);
      }
    }
  });
which gets me JSON like this:
{
    "data": [{
        "id": "2",
        "item": {
            "name": "something here...",
            "company": "1"
        },
        "companies": {
            "name": "my super company"
        }
    }],
    "options": {
        "company": [{
            "value": 2,
            "label": "my second name"
        }, {
            "value": 1,
            "label": "my super company"
        }]
    }
}
In console log I can see my json.options which then I need to populate in this piece of code later in same JS file:
  editor.field('company').update(
    // options.company "value", "label" has to be populated here
  );
How do I access my options variable later in my code, please? Thank you!
The solution
Looks like adjusting my code to something like this, does the trick:
  $.ajax({
      url: '/my-url',
      dataType: 'json'
    })
    .done(callback)
    .done(function(json) {
      for (var i = 0, ien = json.data.length; i < ien; i++) {
        createPanel(json.data[i]);
      }
    });
  function callback(response) {
    var options = response.options.company;
    editor.field('company').update(options);
  }
 
    