Check documentation for the latest version of dhtmlxSuite loadStruct DHTMLX Docs


loads data to the component via XML or JSON, usually component config

promise loadStruct(string|object data, [function doOnLoad] );


datastring|objectXML|JSON URL|string|object
doOnLoadfunction(optional) calls user-defined handler after data is loaded and rendered


promisea "promise" object


var myComponent = new dhtmlXComponent();
// local json/xml object
// local json/xml string
myComponent.loadStruct('<data><node id="a1".../></data>');
// json/xml from server
// local json/xml with callback
myComponent.loadStruct({data:[{id:"a1",..},{id:"a2",..}]}, function(){
    // data loaded and rendered
    // your code here
// local json/xml string with callback
myComponent.loadStruct('<data><node id="a1".../></data>', function(){
    // data loaded and rendered
    // your code here
// json/xml from server with callback
myComponent.loadStruct("server/data.xml", function(){
    // data loaded and rendered
    // your code here
// returns a "promise" object, see details
    // text - a server side response


The type of incoming data will be detected automatically, so you can use this method for loading both XML and JSON in different formats:string, URL from server, object itself.

In the case of loading config from server:

  • async POST request will be performed (that's why you need callback)
    (to use GET instead of POST set dhx.ajax.method = "get", please check details here)
  • to prevent caching in some browsers an extra param like "dhxr0123456789" will be added
    (to disable the extra param set dhx.ajax.cache = true, please check details here)
  • callback order: onXLS event => [request] => onXLE event => doOnLoad()
  • make sure response has the header "Content-Type: text/xml" for XML mode

DHTMLX is integrated with Promiz.js library to treat the result of asynchronous operations (like data loading) without callbacks. Read more about integration of DHTMLX with Promiz.js.

Change log
  • added in 4.0
  • integration with Promiz.js is added in version 5.1
Back to top