Cees Hek wrote:
> I did a talk on AJAX and perl at YAPC Chicago [1] this year. The
slides for most of the talks are online [2], and I added links to my
slides [3] and source code [4].
Hi Cees, thanks I have downloaded the source code and am working my way
through the files. I cannot see any so far that use CGI::Application,
CGI::Ajax and TT, which is what I need to finally succeed. But I think
I'm pretty close now to getting this combination to work using the
following run-mode:
sub display_form {
my $self = shift;
my $msg = shift; # collects results of validate_nhsno()
use CGI::Ajax;
my $pjx = new CGI::Ajax(
validate_nhsno => \&validate_nhsno # NHSNo validation function
);
$pjx->JSDEBUG(1); # dumps AJAX server-calls to web-page
my $ajax_js = $pjx->show_javascript();
$self->tt_params(ajax_js=>$ajax_js, msg=>$msg);
my $output = $self->tt_process('nhs_no.tt2');
return $output;
}
That produces debug output (into the div with id='pjxdebugrequest')
proving that the AJAX part is actually making calls to the server, but
there is obviously still a problem as I don't get the expected error
message in response to an incorrect entry, but do get a double-backslash
appearing on-screen instead: //
It should be possible to click the link produced by JSDEBUG (eg
ajax.cgi?fname=validate_nhsno&args=4068655324&nhs_no=4068655324) and see
what the server is doing with the AJAX request, and indeed on the
non-CGI::Application script the expected string 'invalid NHSNo' is
returned. But on the CGA::App equivalent, the whole web-page is returned
instead.
There is obviously still something missing here, but I cannot see what.
The validation routine does work correctly through the submit button, so
I'm pretty sure the non-AJAX code is correct.
--
Richard Jones
Leeds, UK
mailto:[EMAIL PROTECTED]
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]