Skip to main content
Inspiring
September 20, 2016
Question

Getting data from JSX and store in the global JS scope?

  • September 20, 2016
  • 3 replies
  • 1026 views

I'm developing a HTML5 panel for Photoshop and I have a problem.

I'm using CSInterface.evalScript() to call my JSX function - which returns a bunch of values.

The return is then handled by a function that resides as the second parameter to evalScript() - so far nothing strange (code example below).

var csInterface = new CSInterface();

var lolk = 10;

csInterface.evalScript("myJSX('param1')", function(result){

    lolk = result[8];

});

alert(lolk); // gives 10 - not the value returned from myJSX

The problem here is that I really, really need to be able to output things into the global scope in main.js. But with the above code you will not overwrite the global variable lolk. Instead the assignment is only within the scope of evalScript.

This topic has been closed for replies.

3 replies

Inspiring
January 27, 2017

Hi Heimdaal,

Did you ever find a solution this problem? I'm running into the same issue where i cannot access the updated variable value outside the callback function.

Participant
October 19, 2016

The issue here is that evalScript is returning result[8] asyncronously. You need to put the alert inside the callback after you assign result[8] to lolk.

schroef
Inspiring
December 9, 2024

result[8] is the callback

Inspiring
October 18, 2016

try

lolk = 10;

and not

var lolk = 10;