CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [terrykhatri531] How to pass variable value from perl to Javascript: Edit Log



Zhris
Enthusiast

Aug 8, 2014, 7:34 PM


Views: 42850
Re: [terrykhatri531] How to pass variable value from perl to Javascript

reraised on Stack Overflow.

Fishmonger has given you great advice, you should use it.


Quote
I don't want to pass around $user variable from script to script as there are so many scripts in my application


I think I remember seeing a snippet of your code where you used CGI::Session to create a user session. This is where you could store data such as user. Pass this data to your HTML / javascript whenever you need it, in the same manner as when you pass the current page number to your pagination plugin.

As advised previously, you should break your application into functions, or atleast code that you need to regularly repeat, and put into an external file accessible by all your scripts. One of these functions could fetch user data and be called in each of your scripts i.e. my $user_data = fetch_user_data( @args ). We won't delve into object orientated Perl just yet!

Regards,

Chris


(This post was edited by Zhris on Aug 8, 2014, 8:08 PM)


Edit Log:
Post edited by Zhris (Enthusiast) on Aug 8, 2014, 7:59 PM
Post edited by Zhris (Enthusiast) on Aug 8, 2014, 8:08 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives