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