Michael Peters wrote:
After the client receives the info from the server it needs to process it. Using
the same cases above:
A) JS usually takes that partial document and injects it into the current page
(in prototype this is done with Element.update).
B) Parse the XML and
1 - extra data which is used in some way
2 - use XSLT to transform the XML into HTML
C) use JS eval() to transform the JSON text into a JS object (transparently done
in Prototype) and then use that data in some way.
A sense of deja vu here from many years ago when encountering Perl for
the first time! It only really began to make sense when I was able to
take a working example and de-construct it line-by-line in my own
working environment, and I think the same will apply to AJAX. A working
example of a simple web app built around CGI::Application using AJAX
would be most helpful.
Maybe if you tell us a specific task you're trying to accomplish we can help you
out better and maybe even give you real code :)
That would be most appreciated - if I can get the following to work it
would be a great start. I have an application that registers patient
details, one of which is the NHS number which is a 10-digit unique
identifier for which the 10th digit is a checksum of sorts. At present
the user has to submit the form and wait to see if the NHS number they
have submitted is valid. I have modified the example from the 'Using
Ajax From Perl' article that I referred to earlier to perform this
function, and it works well. Validation is done by a sub-routine
check_nhsno(), so I register this function in AJAX like so:
my $ajax = CGI::Ajax->new( check_nhsno => \&check_nhsno );
The HTML contains the following field with placeholder id="bad_nhsno" to
load the results of the validation:
<p>NHS No: <input type="text" name="nhs_no" id="nhsno"/> <b
id="bad_nhsno"></b></p>
The javascript itself is contained in the snippet 'binding.js' which is
provided with the documentation (no idea what it does), and is loaded in
the page <head> section as standard:
<script type="text/javascript" src="/binding.js"></script>
Then the whole thing is returned using:
print $ajax->build_html( $cgi, \&main );
where main() invokes the check_nhsno() call for the server-side bit, and
constructs the HTML for display.
Migrating this to my CGI:Applicaltion web-app, under the appropriate
run-mode I have essentially the same syntax, except I am using
CAP::AnyTemplate (TT) so the binding.js and necessary placeholder
elements are in the template, and instead of the final line of the
run-mode reading :
$template->output($errors);
I tried:
return $ajax->build_html( $cgi, $template->output($errors) ); #
complains of missing html headers
Obviously not the right thing to do!
***************************************************************************
This e-mail is confidential and privileged. If you are not the intended
recipient please accept our apologies; please do not disclose, copy or
distribute information in this e-mail or take any action in reliance on its
contents: to do so is strictly prohibited and may be unlawful. Please
inform us that this message has gone astray before deleting it. Thank you
for your co-operation.
***************************************************************************
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]