'(CEP/ExtendScript) Is it possible to include a JSX file from a server?
I am developing an extension for InDesign and I would like to store the jsx file on a server. This would allow me to update the plugin if I change something in the jsx without the user having to re-download the extension. I tried to directly do an include in the jsx that is mentioned in the manifest to try to point to the real jsx like this:
local-index.jsx :
//@include "https://server-name/adobe/addins/extendscript/server-index.jsx"
- (local-index would only serve as a bridge between JavaScript and ExtendScript)
- (server-index would contain all the methods I use on the JavaScript side with CSInterface.evalScript();)
It doesn't work and I couldn't find any information on the web. Is it possible or does the jsx file have to be local ?
Thanks in advance !
Solution 1:[1]
You can make AJAX request in local JS to retrieve JSX string from server
See example below
Server side PHP code be like:
<?php
    //JSX Code
    echo 
    "
    alert ('Hello From Server');
    file = new File('~/Desktop/fromServer.txt');
    file.open('w');
    file.write('Hi');
    file.close();
    ";
    
    //OR JSXBIN Code
    //Use eval and remove line breaks from JSXBIN String
    echo "eval('@JSXBIN@[email protected]@MyBbyBn0AFJAnA.....')"; 
?>
JS code client side:
$.ajax({
        type: "GET",
        cache:false,
        url: URL,
        complete: function (Res) {
          scr = Res.responseText;
          csInterface.evalScript(scr);
        },
        async: false //For Synchronous Excecution 
      });
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | 
