I want to load dynamically external JS files in my layout


I’m new to DHTMLX. I have created a basic layout 2U layout. On the cell “a” I have a tree which is loading fine. On the layout cell “b” I want to load dynamically some objects depending upon the choice in the tree. I don’t want to have multiple HTML files. I’m wanting to create a complex application system, much like an ERP product entirely from DHTMLX, PHP and Postgres.

I have external JS files with DHTMLX code (not HTML Files). I want to load them dynamically. I need a way out. I’m currently using the below code to achieve that’s needed:

var loader = dhtmlxAjax.getSync(‘samplegrid.js’);
var k=loader.xmlDoc.responseText;

The file samplegrid.js is in the same folder as index.html. However instead of the grid loading, the entire text of the JS file is displayed as the content of the cell “b”. I tried it with a couple of options but am failing.

My main questions are:
(1) Can we dynamically load external JS files with DHTMLX code. I’m looking at code reuse.
(2) Is there an elegant way like ExtJS MVC thing? If not please give me a work around for this.

Thank you in advance.



a) there is no dhtmlx helper to load js code
b) dhtmlx is not a mvc framework, but UI library. You can use it with any javascript MVC framework