loads data from an external data source.
url | string | the data url |
type | string | (optional) the type of data to load: 'json' (default), 'xml', 'jsarray', 'csv' |
callback | function | (optional) the callback function |
promise | "promise" object |
$$("mylist").load("data.xml", "xml");
The load method can be used with up to three parameters:
$$("component_id").load("some/path/data.json");
$$('component_id').load("some/path/data.json", function(text, data, http_request){
// do something with data.json()
});
$$("component_id").load("some/path/data.xml", "xml", function(text, data, http_request){
// do something with the data object
});
//or
$$("component_id").load("some/path/data.xml", "xml", {
error: function(text, data, http_request){
webix.alert("error");
},
success:function(text, data, http_request){
webix.message("success");
}
});
By default, the loading is asynchronous, so you will need to use the callback to trigger some action after loading is finished.
The callback function takes 3 parameters:
The method returns a Promises/A+ compatible promise object than contains the eventual result of an AJAX request.
Webix uses the Promiz.js library for promises. Learn more at:
The callback can be defined as a combination of error and success functions (you can use only one of them if you want to).
As the load method doesn't provide direct ability to use post and sync, you can use the parse method instead:
// sync data loading
var result = webix.ajax().sync().get("some.json");
$$("component_id").parse(result.responseText);
// using POST for data loading
var result = webix.ajax().post("mydata.php", "some=value", function (text) {
$$("component_id").parse(text);
});
Back to top