Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: javascript on client needs value from server



Permlink Replies: 6 - Last Post: Dec 9, 2017 7:56 AM Last Post By: Joe Sansalone Threads: [ Previous | Next ]
Joe Sansalone

Posts: 158
Registered: 1/15/06
javascript on client needs value from server
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 8, 2017 3:09 PM
Hi,

I need to create a JSON Web Token on the server (using a HASH and a secret key) and then
pass it to a javascript function on the client.

How does one pass a value to the client javascript function from the server via IntraWeb?

Joe
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: javascript on client needs value from server
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 8, 2017 3:21 PM   in response to: Joe Sansalone in response to: Joe Sansalone
Joe Sansalone wrote:

I need to create a JSON Web Token on the server (using a HASH and a
secret key) and then pass it to a javascript function on the client.

How does one pass a value to the client javascript function from the
server via IntraWeb?

I don't know the specifics of doing something like this in IntraWeb,
but typically this is done by the client using AJAX or WebSocket to
issue a request to the server without having to leave the current web
page.

--
Remy Lebeau (TeamB)
Joe Sansalone

Posts: 158
Registered: 1/15/06
Re: javascript on client needs value from server
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 8, 2017 3:34 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Joe Sansalone wrote:

I need to create a JSON Web Token on the server (using a HASH and a
secret key) and then pass it to a javascript function on the client.

How does one pass a value to the client javascript function from the
server via IntraWeb?

I don't know the specifics of doing something like this in IntraWeb,
but typically this is done by the client using AJAX or WebSocket to
issue a request to the server without having to leave the current web
page.

--

I understand. IntraWeb already uses AJAX to execute code on the server
and pass values back to the client.
I'd like to know how to "inject" my own javascript AND also reference a value/var
on the server.

Looking for how IntraWeb allows for custom javascript and how to reference
vars on the server ...

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: javascript on client needs value from server
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 8, 2017 4:49 PM   in response to: Joe Sansalone in response to: Joe Sansalone
Joe Sansalone wrote:

Looking for how IntraWeb allows for custom javascript and how to
reference vars on the server ...

This should be covered in IntraWeb's documentation.

--
Remy Lebeau (TeamB)
Dan Barclay

Posts: 889
Registered: 11/9/03
Re: javascript on client needs value from server
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 8, 2017 7:48 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Joe Sansalone wrote:

Looking for how IntraWeb allows for custom javascript and how to
reference vars on the server ...

This should be covered in IntraWeb's documentation.
The IW demos on github are sometimes the best for showing techniques. I seem to recall one of the demo projects doing this but I’m not at a computer now.

Dan
Jose Nilton Pace


Posts: 122
Registered: 5/15/98
Re: javascript on client needs value from server
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 9, 2017 4:00 AM   in response to: Joe Sansalone in response to: Joe Sansalone
Hi joe. You can pass javascript var in your Create || Render || Show Form like this:
procedure TIWForm1.IWAppFormShow(Sender: TObject);
begin
   Self.JavaScript.Clear;
   Self.JavaScript.Add( 'var myToken = ''' + myGeneratedToken + ''';' );
end;
Joe Sansalone

Posts: 158
Registered: 1/15/06
Re: javascript on client needs value from server
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 9, 2017 7:56 AM   in response to: Jose Nilton Pace in response to: Jose Nilton Pace
Jose Nilton Pace wrote:
Hi joe. You can pass javascript var in your Create || Render || Show Form like this:
procedure TIWForm1.IWAppFormShow(Sender: TObject);
begin
   Self.JavaScript.Clear;
   Self.JavaScript.Add( 'var myToken = ''' + myGeneratedToken + ''';' );
end;

What about on a button click?
I'd like to generate the token on the server and then execute some javascript on the client
using that token.
I suspect that ScriptsEvent is where I add the javascript ... I just realized that I could add the literal value
of the token to the javascript (ScriptsEvent) .. this would get it passed back to the client.

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02