I was able to overcome the IE cache problem on AJAX with the following headers in PERL CGI.
my $q = CGI->new;
print $q->header( -head => $q->meta({ '-http_equiv'
=> "cache-control", '-content' => "no-cache" }),
-expires => 'now');
Thursday, July 10, 2008
Wednesday, April 2, 2008
perl hash sort values example CGI script
In the following example what we are trying to do is to sort the Value part of the Hash and display it inside a popup menu sorted by the value rather than the key.
#!/usr/bin/perl
use CGI;
my $qry = CGI->new();
my %c = (
"1016"=>"W",
"1017"=>"Cl",
"1018"=>"Fu",
"1023"=>"Emerg",
"1024"=>"Responsibler",
"1025"=>"Director",
"1026"=>"Accountable"
);
$default = 1017;
my $html = $qry->popup_menu (
-name=>"XXX",
-values=>[sort { $c{$a} cmp $c{$b} } keys %c],
-labels=>\%c,
-override=>'true',
-default=> ( $default )
);
print $html;
#!/usr/bin/perl
use CGI;
my $qry = CGI->new();
my %c = (
"1016"=>"W",
"1017"=>"Cl",
"1018"=>"Fu",
"1023"=>"Emerg",
"1024"=>"Responsibler",
"1025"=>"Director",
"1026"=>"Accountable"
);
$default = 1017;
my $html = $qry->popup_menu (
-name=>"XXX",
-values=>[sort { $c{$a} cmp $c{$b} } keys %c],
-labels=>\%c,
-override=>'true',
-default=> ( $default )
);
print $html;
Tuesday, February 19, 2008
Sample Ajax function call
function xmlhttpPost(strURL) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(getquerystring());
}
Cloning Data Objects in perl
use Storable qw/dclone/;
my $hash =
$newhash = dclone($hash);
You may get an error if you try to simply use an equal to sign within in a Perl object.
my $hash =
$newhash = dclone($hash);
You may get an error if you try to simply use an equal to sign within in a Perl object.
Subscribe to:
Posts (Atom)