in reply to Re^3: Using CGI::Ajax for multiple form buttons/divs simultaneously
in thread Using CGI::Ajax for multiple form buttons/divs simultaneously

To help me remember this myself in the future, should I seek to utilize CGI::Ajax again, I wish to make the following response to what you have mentioned above.

Everything must be executed from within the &main subroutine. Anything else will fall outside of the purview of Ajax upon callback from the client.

I had organized my code, as I usually do, by taking care of preliminaries before running the main subroutine--such as collecting my form inputs and setting up default values to certain variables. But instead of "compartmentalizing" things like this, and running them in their necessary A-B-C order, with Ajax, I have learned I must "nest" everything into the main subroutine.

It seems someone could update the Ajax explanations, which I think I have read several times without realizing this fact, with a little more clarity. The TIMTOWTDI philosophy seems rather narrowed by the use of CGI::Ajax, for the code must be structured in just the right way to make it work.

As for the "big mess of javascript," I have found CGI::Ajax far less unwieldy than jQuery and similar options which seem more popular. I'm happy with the small amount of JavaScript that the Ajax adds to the page.

Blessings,

~Polyglot~

  • Comment on Re^4: Using CGI::Ajax for multiple form buttons/divs simultaneously