Insert elements loaded from js script ajax

Is it possible to define/create new elements loaded from response of AJAX (body of response is a js script, no json object)?

Good day @Revencu,

To request JS script and be able to use it, you can use webix.require or jQuery.

Webix.require will add the script to the page:

webix.require("extras.js");

in jQuery, this is a widely used $.ajax method. You can call scripts through its correct dataType: W3Schools Tryit Editor

Speaking abour regular requests, Webix has webix.ajax. Webix.ajax uses the classic XMLHttpRequest, or you can use the modern Fetch.

They differ only in the methods of processing the response.

Also, please note, that it`s necessary to separate the implementation methods clearly:

  • usage of regular Ajax requests to receive data is more often. The file can be any kind of file, like .txt and .xml.

  • a script is executable code that is not available for use if you request a .js file via regular Ajax.
    However, you can get the content of the desired .js file as text, add a <script> tag (createElement) to the page and add content there.