Subject: | Double Content-Type when using CGI::Ajax in a CGI::Application-App (with patch) |
It would be nice to deactivate the header information. When you use
CGI::Ajax within a CGI::Application app, you have to use a RegEx to
filter the header information.
The attached file contains a patch that adds a "skip_header" method to
Ajax.pm
The other file is a testscript...
Subject: | Ajax.diff |
11c11
< js_encode_function cgi_header_extra);
---
> js_encode_function cgi_header_extra skip_header);
15c15
< $VERSION = .701;
---
> $VERSION = .702;
33d32
<
57a57,67
> When you use CGI::Ajax within Applications that send their own header information,
> you can skip the header:
>
> my $pjx = new CGI::Ajax(
> 'exported_func' => \&perl_func,
> 'skip_header' => 1,
> );
> $pjx->skip_header(1);
>
> print $pjx->build_html( $cgi, \&Show_HTML);
>
488a499
> return '' if $self->skip_header;
530c541
< if ( !defined $html ) {
---
> if ( !defined $html and $self->skip_header == 0 ) {
552c563
< if ( !defined $html ) {
---
> if ( !defined $html and $self->skip_header == 0 ) {
649a661,666
>
> if( $function_name eq 'skip_header' ){
> $self->skip_header( $code );
> next;
> }
>
1094c1111
< if ( !defined $rv ) {
---
> if ( !defined $rv and $self->skip_header == 0 ) {
Subject: | ajax_patch.pl |
#!/usr/bin/perl
use strict;
use warnings;
Test->new->run;
package Test;
use strict;
use warnings;
use CGI::Ajax;
use base qw(CGI::Application);
sub setup{
my ($self) = @_;
$self->run_modes(
AUTOLOAD => \&test,
);
}
sub test{
my ($self) = @_;
my $ajx = CGI::Ajax->new(
test => \&hallo,
skip_header => 1,
);
# alternativly
$ajx->skip_header(1);
my $html = do{ local $/; <DATA> };
return $ajx->build_html( $self->query, $html );
}
__DATA__
<html>
<head>
</head>
</html>