#2806 call javascript function from fantom

Vojtěch Musílek Mon 13 Jul 2020

Hi, I'm new to fantom and i have simple problem. I have my .js file in js dir and i have my testLib in fan dir (generated using stub tool). I have made simple example how i expect it to work:

.js file with jsAdd function called from fantom and then fanAdd called from skyspark

--JS--
function jsAdd(a, b) { return a + b; }

--FANTOM--
@Axon
static Int fanAdd(Int a, Int b)
{
  return <my-js-file?>.jsAdd(a, b)
}

But i don't know the part where you call .js file from fantom and if that's even possible.

SlimerDude Mon 13 Jul 2020

Hi Vojtěch,

Implicit in your question is that the Axon function fanAdd() is run in the browser, whereas that is not the case. Fantom Axon functions are run on the server and hence can not call out to Javascript.

For further clarification, I would ask on the SkySpark forum as this is probably more of a SkySpark question than it is an Fantom one.

Login or Signup to reply.