简体   繁体   English

从Webix中结果对象的属性加载数据

[英]Load data from a property of the result object in Webix

I have a Webix list and want to load data dynamically. 我有一个Webix列表 ,想动态加载数据。 The problem is that the data is under the results.entries key in the JSON object returned by the AJAX call. 问题在于数据在AJAX调用返回的JSON对象中的results.entries键下。 How should I load that data? 我应该如何加载该数据?

So far what I came up with is slightly convoluted: 到目前为止,我的想法有些复杂:

var result = webix.ajax().sync().get('/my-rest-endpoint');
$$('mylist').parse(JSON.parse(result.responseText).results.entries);

With sync() method, callback is synchronous. 使用sync()方法,回调是同步的。 But I recomended to you if your '/my-rest-endpoint' has a waiting time to be generated, use ajax async() method, like this example 但是,如果您的'/ my-rest-endpoint'有一个等待时间要生成,我建议您使用ajax async()方法,例如本例

webix.ajax().get('/my-rest-endpoint',{
    // Error callback
    error:function(text, data, XmlHttpRequest){
        alert("error");
    },

    //Success callback
    success:function(text, data, XmlHttpRequest){
        var data = JSON.parse(text);
        $$('mylist').parse(data.results.entries);
    }
});

Regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM