6 ## Everything a scrap does should be enclosed in an eval{} statement to catch errors.
9 my $scrap = CXGN
::Scrap
->new();
11 my %args = $scrap->get_all_encoded_arguments();
16 <head><title>Scrap Test</title></head>
17 <body style='font-family:arial, sans-serif'>
18 This page is a scrap. It uses <b>CXGN::Scrap</b> as opposed to <b>CXGN::Page</b> to grab arguments. This reduces overhead for things we don't need, such as standard SGN/Secretary page headers and footers.
20 The purpose of scraps is to receive arguments and perform database-related actions behind the scenes. Generally, a scrap receives it's request via an <b>AJAX</b> method in <b>Javascript</b>. It should return some kind of simple textual reply that can be parsed by Javascript, but it doesn't really have to print anything at all.
22 This page wouldn't be an ideal scrap for Javascript-parsing since it contains html tagging and a little css, but you get the idea.
24 Try the following link to make sure the argument-getting is working:
25 <a href='test.pl?something=intheway&esta_bien=1&yadda=kostanza'>This page, w/ args</a>
27 <a href='test.pl'>This page, no args</a>
29 Here is a list of arguments sent to this scrap:
32 while(my($key, $value) = each %args) {
33 print "<br><em>Key:</em> $key => <em>Value:</em> $value";
40 Here is the code for this page. Notice that all of the scrap methods are enclosed in eval{} tags, so that an AJAX request does not receive an SGN error page, but rather a more simple Error expression that is parse-able:
47 ## Everything a scrap does should be enclosed in an eval{} statement to catch errors.
50 my \$scrap = CXGN::Scrap->new();
52 my \%args = \$scrap->get_all_encoded_arguments();
57 <head><title>Scrap Test</title></head>
59 ... Everything you see above ...
61 Here is a list of arguments sent to this scrap:
64 while(my(\$key, \$value) = each \%args) {
65 print "Key: \$key => Value: \$value";
72 ## This is the preferred method for scraps to generate errors. The standard SGN error page will be very difficult for Javascript to parse, in case a die, confess, or croak gets called.
75 ##Everytime a scrap messes up, the AJAX request will begin with "Error:". This allows JS-side error-catching to be handled fairly easily.
81 ## This is the preferred method for scraps to generate errors. The standard SGN error page will be very difficult for Javascript to parse, in case a die, confess, or croak gets called.
84 ##Everytime a scrap messes up, the AJAX request will begin with "Error:". This allows JS-side error-catching to be handled fairly easily.