annotate scripts/pjx_NO_CACHE_caller.pl @ 3:2e849c856026 boosterpack

[svn r5] it works!
author robert
date Tue, 08 Sep 2009 05:55:51 -0400
parents 477258d09353
children
rev   line source
robert@0 1 #!C:/strawberry/perl/bin/perl.exe
robert@0 2
robert@0 3 # this is an script calls an external script and avoids caching:
robert@0 4 # NB The CGI::Ajax object must come AFTER the coderefs are declared.
robert@0 5
robert@0 6 use strict;
robert@0 7 use CGI::Ajax;
robert@0 8 use CGI;
robert@0 9
robert@0 10 my $q = new CGI;
robert@0 11
robert@0 12 my $Show_Form = sub {
robert@0 13 my $html = "";
robert@0 14 $html .= <<EOT;
robert@0 15 <HTML><title>CGI::Ajax No_Cache Example</title>
robert@0 16 <HEAD>
robert@0 17 </HEAD>
robert@0 18 <BODY>
robert@0 19 <i>
robert@0 20 If the same URL is requested, A browser may cache the result
robert@0 21 and return it without querying the requested URL. To avoid that, use
robert@0 22 the 'NO_CACHE' keyword as a parameter in your javascript function.
robert@0 23 </i><br/>
robert@0 24 <form>
robert@0 25 Click the button and a perl script 'pjx_NO_CACHE_callee.pl should
robert@0 26 return the current time:<br/><br/>
robert@0 27
robert@0 28 <input type="button" id="b1" size="6" value='This will cache (in IE)' onclick="perl_script([], ['out1']);return false"><br/>
robert@0 29
robert@0 30 <input type="button" id="b2" size="6" value='This will NOT cache' onclick="perl_script(['NO_CACHE'], ['out1']);"><br/>
robert@0 31
robert@0 32 New Time:<input type=text id="out1">
robert@0 33
robert@0 34
robert@0 35 </form>
robert@0 36 </BODY>
robert@0 37 </HTML>
robert@0 38 EOT
robert@0 39
robert@0 40 return $html;
robert@0 41 };
robert@0 42
robert@0 43 my $pjx = CGI::Ajax->new( 'perl_script' => 'pjx_NO_CACHE_callee.pl');
robert@0 44 $pjx->JSDEBUG(1);
robert@0 45 $pjx->DEBUG(1);
robert@0 46 print $pjx->build_html($q,$Show_Form); # this outputs the html for the page