如何在瀏覽器上加載html頁面時運行perl腳本。我試圖運行perlscript onload(),甚至將它寫在頭上。但沒有奏效 perl腳本:在加載html頁面上運行perl腳本
#!/usr/bin/perl -w
use strict;
use CGI ':standard';
use warnings;
use FileHandle;
my $result="sakshi";
open(OUT,'>/var/cgi-bin/sample.html');
print
OUT header(),
start_html(
-title => 'Command',
-text => '#520063'
);
print OUT "Hello $result";
print OUT end_html();
close(OUT);
事情,我在HTML曾嘗試:
1.
<head>
<title>test</title>
<script src="common_info.pl"></script>
</head>
2.
<body onload=call_perl()">
<script text/javascript>
function call_perl(){
var ajax = new XMLHttpRequest;
ajax.open("GET", "http://localhost/cgi-bin/myscript.pl", true);
ajax.send();
}
</script>
你想完成什麼?發佈的代碼沒有任何意義。 –