in reply to Re: mod_perl & ajax
in thread mod_perl & ajax
Now the one with Ajax:package dir_browse::dir_browse; use strict; use warnings; use Apache2::RequestRec; use Apache2::RequestIO; use Apache2::Const qw(:common); use Apache2::Reload; use File::Spec; use Error qw(:try); use Template; sub new { bless {} } sub handler : method { my ($self, $r) = @_; $Error::Debug = 1; $self = $self->new unless ref $self; $self->{r} = $r; try { my $websrc = $self->get_websrc; my $template = new Template({ INCLUDE_PATH => ["$websrc/src", "$websrc/lib"], INTERPOLATE => 1, OUTPUT => $self->{r}, }); $self->get_contents(File::Spec->rel2abs($self->{r}->path_info) +); $self->{r}->content_type('text/html'); throw Error(-text => "No path '$websrc'") unless -f "$websrc/s +rc/dir_browse.tt2"; $template->process('dir_browse.tt2', $self) or throw Error(text => $template->error()); } catch Error with { my $E = shift; $self->{r}->print($E->stacktrace); $self->{r}->log_error($E->stacktrace); return Apache2::Const::SERVER_ERROR; }; return Apache2::Const::OK; } ... 1;
And the httpd.confLpackage dir_browse::dir_browse; use strict; use warnings; use Apache2::RequestRec; use Apache2::RequestIO; use Apache2::Const qw(:common); use Apache2::Reload; use Apache2::Ajax; use File::Spec; use Error qw(:try); use Template; sub new { bless {} } sub handler : method { my ($self, $r) = @_; $Error::Debug = 1; $self = $self->new unless ref $self; $self->{r} = $r; try { my $websrc = $self->get_websrc; my $template = new Template({ INCLUDE_PATH => ["$websrc/src", "$websrc/lib"], INTERPOLATE => 1, OUTPUT => $self->{r}, }); $self->get_contents(File::Spec->rel2abs($self->{r}->path_info) +); $self->{r}->content_type('text/html'); throw Error(-text => "No path '$websrc'") unless -f "$websrc/s +rc/dir_browse.tt2"; my $html; $template->process('dir_browse.tt2', $self, \$html) or throw Error(text => $template->error()); my $ajax = Apache2::Ajax->new($self->{r}, 'show' => sub {retur +n $html}) or throw Error(text => "DARN!! "); $self->{r}->print($ajax->build_html()); } catch Error with { my $E = shift; $self->{r}->print($E->stacktrace); $self->{r}->log_error($E->stacktrace); return Apache2::Const::SERVER_ERROR; }; return Apache2::Const::OK; } ... 1;
And here is the error message I get when I rum this:PerlModule Apache2::Ajax ... PerlModule Apache2::dir_browse <Location /dir_browse> SetHandler perl-script PerlResponseHandler dir_browse::dir_browse </Location>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: mod_perl & ajax
by randyk (Parson) on Apr 11, 2007 at 17:59 UTC | |
by artemave (Beadle) on Apr 12, 2007 at 11:41 UTC | |
by Anonymous Monk on Jul 05, 2008 at 10:35 UTC | |
|
Re^3: mod_perl & ajax
by ides (Deacon) on Apr 11, 2007 at 16:06 UTC |