Get json data from server into a variable

I’m trying to get data from server, save it to a variable and use it in a data table, like this:

var configcolumns = webix.ajax().get(“data.php”,{table:“mytable”, command:“getFields”}, function (text,data,xhr){ return data}
//This example goes to data.php that read my table parameter, and my command parameter and returns this:
[{‘id’:‘id’, ‘header’:‘ID’},{‘id’:‘name’,‘editor’:‘text’, ‘header’:‘Name’}]

Now, use configcolumns as definition of columns on my datatable:
var datatable = webix.ui({
view:“datatable”,
columns: configcolumns,
etc…

});

The problem is I don’t receive the json data on configcolumns, I receive a e.promise objects and I don’t know how to extract the json data I send from data.php.

if I do a console inside the function like this:
var configcolumns = webix.ajax().get(“data.php”,{table:“mytable”, command:“getFields”}, function (text,data,xhr){ console.log(text);console.log(data.json());return data}
I see on console my json data correctly, but this data is not assigned to configcolumns.

How I need to do to get some json data from a server and assign it to a variable?

Thanks

webix.ajax().get("data.php",{table:"mytable", command:"getFields"},
function (text,data,xhr){
   $$("mytable").define("columns",data.json());
   $$("mytable").refreshColumns();
})

but I would prefer to create datatable after receiving configuration.

Thanks Integral! It’s perfect for my point!!
In the other side, is there any webix function to catch json values returned to a variable? It’s no only to change dynamically some configuration but to work with others variables outside webix’s widgets.
similar to webix.ajax() but I could have returned value to a variable .

var config;
webix.ajax().get("data.php",{table:"mytable", command:"getFields"},
function (text,data,xhr){
   config = data.json();
   do_next_operations();
})

Oops … I feel so stupid … hahaha
Thanks again Integral!