AJAX response to update Tree data


I have the following snippet of code and would like to be able to fetch the data fetch server-side data based on the selection in the combo.
So far this works and gets the data from the server but I can't figure out how to update this data to the tree menu.

<script type="text/javascript" charset="utf-8">
    var combo = webix.ui({
        container: 'combo_menu',
        view: "combo",
        label: "Unit",
        labelPosition: "top",
        labelAlign: 'left',
        placeholder: "Select Unit",
        id: "bu_select",
        options: "rest->/units.json",
        button: true

    var tree = webix.ui({
        container: "tree_menu",
        view: "tree",
        id: "treeMenu",
        select: true,
        height: 500,
        data: []

    webix.ready(function () {

    $$("bu_select").attachEvent("onChange", function (sel, oldv) {
        webix.message("Value changed from: " + oldv + " to: " + sel);

            url: "tree_data",
            type: "GET",
            dataType: 'script',
            data: {bu_id: sel},
            success: function (data) {

This does not work.

Any help is appreciated.



  • I figured it out. And using the built-in webix ajax made it more succinct.

        $$("bu_select").attachEvent("onChange", function (sel,) {
          webix.ajax().get("nodes_by_bu", "bu_id=" + sel, function(text,data){
  • Hello,

    Sorry for the delay.
    You can use onChange event. To clear data, you need to call clearAll() method. And, after this, you need to parse incoming data to the component with the help of parse method

    combo.attachEvent("onChange",  function(value, old){
       webix.ajax().get( "url", { param:value }, function(text, data, xhr){

    Information about Ajax operations you can find here.

    Also, webix.ajax support promise:

    webix.ajax().get( "url", { param:value }).then(function(data){
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!