http://www.perlmonks.org?node_id=791191


in reply to Re^2: Using CGI::Ajax and CGI::Application::Plugin::DBH
in thread Using CGI::Ajax and CGI::Application::Plugin::DBH

The problem is that when called through CGI::Ajax, 'BUILD_CHART' doesn't utilize runmodes. It dynamically builds the XMLHTTP request and, as far as i can tell, is able to bypass the instance script altogether.

Sure it does not all work together out of the box. But I've given suggestions as to how to make it work.

It occurred to me while talking this over with a coworker that it's likely going to require a port from cgi to mod_perl to achieve the persistent connection in the background.

There is nothing in what you are trying to do that requires this. As I mentioned already, you are going to have to do one of A) modify CGI::App or CGI::Ajax to your liking, B) use the CGI::App plugin system to make a shim for what you need, or C) subclass one or the other or both to get the CGI::App object in to the CGI::Ajax callback.

Again, at the very least, if you simply call:

my $dbh = MyApp->new->dbh;

in the CGI::Ajax callback you should be all set.