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