set global JavaScript variable

Hi,
I have some variables stored in my config table. I want to set a global JavaScript variable from them. e.g.
$siteconf = new SiteConfig();
$pubKey = $siteconf->PublicKey;

NOW, I want to set a global JavaScript variable with $pubKey value.

How I can set that variable? How to call the variable in my JS files?

Thanks

Use the built in function “SetClientVar” in your server event codes. For example:

SetClientVar(“myname”, “myvalue”);

You can then retrieve the variable on client side via: ew.vars.myname.