PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Sharing variables between JS and WL in WB v.22
Sharing variables between JS and WL in WB v.22
Iniciado por guest, 30,nov. 2017 19:39 - 5 respuestas
Publicado el 30,noviembre 2017 - 19:39
Hello All:

I'm using WB v.22 and I have some JavaScript code running on the Browser side. Is there any way to share/access variables between JS and WL? I need to pass data to the JS function from the WL server functions.

Thanks
Gus
Publicado el 30,noviembre 2017 - 21:11
Clarification:

I actually have to call a Browser code in JavaScript from the server side, to pass new data. Is it possible to call browser code from the server side?

Thanks
Gus
Publicado el 30,noviembre 2017 - 22:49
Server don't know anything about what is executed on client side, of course! Server just serves client requests. You can take some information from server using jQuery (AJAX) for example or learn the new feature of WD22 websockets. In any case initial request executed from client.
Publicado el 01,diciembre 2017 - 07:18
Hi, as far as I know:

Is there any way to share/access variables between JS and WL?
YES

Is it possible to call browser code from the server side?
NO
Publicado el 01,diciembre 2017 - 20:30
Thank you all for the answers...
Specially Fabrice for such a great advice.

Regards;
Gus
Publicado el 04,diciembre 2017 - 17:51
Yes! I also do what fabrice does! You can also pass parameters to a JS procedure from WL, Create a web procedure from WebDev, and change it to JS, in the parenthesis of your procedure declare the parameters you want to receive, and you can also retrieve values from the JS procedure with return or you can also use JS or JQuery to write some value in an EDT_, depending on the circumstance you may use this or the timer Fabrice told you, because when you execute a JS procedure your code will continue, without waiting for this procedure to finish, so sometimes your server side won't see the value your JS wrote in an EDT_, in this case is better to use a timer.