in reply to Global variables with CGI:Ajax

I have found that each "callback" does not persist the data to the global hash when printed in each subroutine.

Yeah, in-memory-data does not persist between different processes, when the process ends, the data is gone

To persist the data you would use a server-side-cache, like CGI::Session, Apache::Session, CHI ...

Read more about memory management at Re^3: Scope of lexical variables in the main script

Replies are listed 'Best First'.
Re^2: Global variables with CGI:Ajax
by me_gazza (Initiate) on May 29, 2012 at 08:23 UTC

    Thanks for the info. I just did a simple print FILE test using $$ on the name and can see as you say it is a different process each time. This implies the entire screen on the browser is refreshed for each AJAX call right? I thought AJAX (in my simple mind) was clever in that it simply modified the element (div) on screen and used the called script/function to provide the modification?

    I am wondering why I both using AJAX in that case and just let the entire HTML page refresh with some hidden variables to control what actions occur on the next call of the cgi object.

    Any thoughts on that?

    Many Thanks

      This implies the entire screen on the browser is refreshed for each AJAX call right?

      Nope, it implies each HTTP request AJAX makes is serviced by a different CGI program instance.

      Read more about this (watch the video too) at learn about the internet,Web Programming: For Beginners, to get an overall picture of how the internet works, how tcp/ip, sockets, html, ajax, all fit together.