在包含 jquery-1.11.3.min.js 之后,浏览器不会 react/update 到 perl CGI redirect/print html

Browser does not react/update to perl CGI redirect/print html after including jquery-1.11.3.min.js

我正在尝试使用 perl 和 CGI​​ 实现一个基本的用户授权系统。浏览器(firefox 和 safari)不会对 CGI 重定向(成功登录到新页面后)做出反应,甚至不会对包含 jQuery[=60= 后的简单打印 HTML 做出反应] 1.11.13.min.js在HTML登录页面的header。浏览器的内容区域和 url 文本框保持不变,因为 CGI 脚本从未执行过。但我知道脚本已执行。

系统总结如下:
用户首先会看到一个 HTML 登录页面 (login_page.html),其中包含一个带有 'username' 和 'password' 字段的基本登录表单,表单操作是一个 cgi 脚本 (verify.cgi) 使用 POST.

调用

此脚本检查凭据是否正确,然后 重定向 到新的 CGI 脚本 (welcome.cgi),该脚本在 HTML 中打印基本的欢迎消息,或者只是在那里打印一条基本的 html 失败消息(所有三个文件都包含在 post 的下方)。

但是,重定向到欢迎 (CGI) 页面后出现问题。 welcome.cgi 脚本被成功调用,因为我让它在服务器的文件中打印一条消息。 但是 浏览器(firefox 41.0.2 和 safari 6.2.4)的 url-address 框没有更新,http://..../verify.cgi url 仍然存在。此外,浏览器显示登录页面 html 并且不会通过 verify.cgi/welcome.cgi 将其内容区域更新为欢迎或登录失败消息 html output-ed脚本。

在我的登录页面的 header 中包含标准 jQuery js 文件 (http://code.jquery.com/jquery-1.11.3.min.js) 后出现问题(在 html 中)。

谁能帮我找出我做错了什么以及如何解决它?

请不要问我为什么要包括jQuery。而且我更喜欢坚持使用 perl。

欢迎对代码和设计提出一般性意见。

非常感谢

以下是最基本形式的三个文件:

  1. login_page.html
<!doctype html>
<html>
<head>
<!-- this one creates a problem with CGI redirect -->
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>

<!-- this one does not seem to create any problem -->
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

</head>
<body>
<form action="/bin/verify.cgi" method="post" name="login_form">
 <input type="text" name="username" id="username"><br/>
 <input type="password" name="password" id="password"><br/>
 <input type="submit" value=" Log In " name="login_button"/>
</form>
</body>
</html>
  1. verify.cgi
#!/usr/bin/env perl

use strict;
use warnings;
use CGI::Carp;
use CGI::Session;
use CGI;

my $cgi = CGI->new;

my $username = $cgi->param("username");
my $password = $cgi->param("password");

if( defined($username) &&
    defined($password) &&
    ($username eq 'test') &&
    ($password eq 'test')
){
    # successful login
    my $session = CGI::Session->new(
        "driver:File",
        undef,
        {Directory=>'/tmp'}
    );
    my $sid = $session->id();
    $session->param('username', $username);
    # setup the cookie to the session
    my $cookie = $cgi->cookie(
        -name  => 'CGISESSID',
        -value => $sid
    );
    $session->save_param();
    $session->flush();
    # move on to the next page and place the cookie in the headers
    # the script in the -location is EXECUTED OK - so redirect works
    # however browser does not update URL textbox nor its content page:
    print $cgi->redirect(
            -cookie   => $cookie,
            -url => 'http://c3.myartsonline.com/bin/welcome.cgi'
    );
    # even with this it does not work
    # print $cgi->header() . "<html><body>welcome, login successful</body></html>";

} else {
    # login failed
    # this I can not see in the browser either
    print $cgi->header() . '<html><body>login failed</body></html>';
}
1;
__END__
  1. welcome.cgi
#!/usr/bin/env perl

use strict;
use warnings;
use CGI;
use CGI::Session;
my $cgi = CGI->new;

my ($session, $username) = (undef) x 2;

my $sid = $cgi->cookie('CGISESSID') || $cgi->param('CGISESSID') || undef;
if( defined($sid) ){
    $session = CGI::Session->new(undef, $sid, {Directory=>'/tmp'});
    if( defined($session) ){
        $username = $session->param('username')
    }
}
if( defined($username) ){
    print $cgi->header() . "<html><body>welcome user '$username', login successful</body></html>";
    open(OUT, ">hello");
    print OUT "weclome\n";
    close(OUT);
} else {
    print $cgi->header() . "<html><body>please login first</body></html>";
}
1;
__END__

添加

data-ajax="false"

到表单定义(例如<form data-ajax="false" ....>) 在文件中 login_page.html

问题解决。现在浏览器的 url 文本框和内容区域在执行 CGI::redirect() 时会正确更新。

这会破坏其他东西吗?谁知道呢