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