Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Calling Perl function and script from javascript and backwards

by peacemaker1820 (Pilgrim)
on Jul 17, 2002 at 15:30 UTC ( #182460=perlquestion: print w/replies, xml ) Need Help??

peacemaker1820 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Guys!
How do I call a Perl function or a perl script from javascript method and then return values back to javascript. OR the other way around: to call a javascript function from perl and return back the values that were passed or somehow?
Is there a way to do this?
Any ideas??? :)
~~~Peace~~~

Replies are listed 'Best First'.
Re: Calling Perl function and script from javascript and backwards
by rinceWind (Monsignor) on Jul 17, 2002 at 15:47 UTC
    Hi there peacemaker1820,

    What exactly are you trying to do? There is an important distinction between what is happening client side i.e. Javascript, and what is happening inside a CGI application, which happens server side.

    It could be that you are using ActiveState's perlscript and both Perl and Javascript are happening client side. But, I assume that your Perl is running server side.

    Note, for Javascript to call a CGI application, it does this by invoking a new URL. This causes the browser to bring up a new page, without passing back a return value, because you are not returning into the Javascript.

    One possibility though is to use frames. The new URL is loaded into a different target frame, and the new page for this frame contains some Javascript to call a function in your original frame to signify completion.

    hth --rW

Re: Calling Perl function and script from javascript and backwards
by epoptai (Curate) on Jul 17, 2002 at 15:37 UTC
Re: Calling Perl function and script from javascript and backwards
by gav^ (Curate) on Jul 17, 2002 at 17:19 UTC
    You could use a framework like OpenThought:
    OpenThought is a powerful and flexible web application environment. OpenThought applications are different from other web applications in that all communication between the browser and the server is performed in the background. This gives a browser the ability to receive data from the server without ever reloading the currently loaded document. Data received can be displayed automatically on the existing page, can access JavaScript functions and variables, and can load new pages. Additionally, OpenThought completely manages all of your session data for you. These features give the look and feel of a full-blown application instead of just an ordinary Web page.
    I've not ever used it, but I have done a similar thing, basically using a hidden frame and javascript. You call a cgi script which returns javascript code to do things.

    Hope this helps..

    gav^

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://182460]
Approved by rinceWind
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2020-11-27 10:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?